Re: [PATCH] et8ek8: Add support for flash and lens devices

2017-09-12 Thread Sakari Ailus
Hi Pavel,

On Mon, Sep 11, 2017 at 03:18:31PM +0200, Pavel Machek wrote:
> Parse async sub-devices by using
> v4l2_subdev_fwnode_reference_parse_sensor_common().
> 
> These types devices aren't directly related to the sensor, but are
> nevertheless handled by the et8ek8 driver due to the relationship of these
> component to the main part of the camera module --- the sensor.
> 
> Signed-off-by: Pavel Machek 
> 
> ---
> 
> This enables me to do autofocus on n900.
> 
> Depends on Sakari's series, so best solution would be to append it there.

I added this after the smiapp driver changes.

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


[PATCH] et8ek8: Add support for flash and lens devices

2017-09-11 Thread Pavel Machek
Parse async sub-devices by using
v4l2_subdev_fwnode_reference_parse_sensor_common().

These types devices aren't directly related to the sensor, but are
nevertheless handled by the et8ek8 driver due to the relationship of these
component to the main part of the camera module --- the sensor.

Signed-off-by: Pavel Machek 

---

This enables me to do autofocus on n900.

Depends on Sakari's series, so best solution would be to append it there.

Thanks,
Pavel

diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c 
b/drivers/media/i2c/et8ek8/et8ek8_driver.c
index c14f0fd..cd1f15f 100644
--- a/drivers/media/i2c/et8ek8/et8ek8_driver.c
+++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c
@@ -34,10 +34,12 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "et8ek8_reg.h"
 
@@ -46,6 +48,7 @@
 #define ET8EK8_MAX_MSG 8
 
 struct et8ek8_sensor {
+   struct v4l2_async_notifier notifier;
struct v4l2_subdev subdev;
struct media_pad pad;
struct v4l2_mbus_framefmt format;
@@ -1446,6 +1449,11 @@ static int et8ek8_probe(struct i2c_client *client,
sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
sensor->subdev.internal_ops = _internal_ops;
 
+   ret = v4l2_fwnode_reference_parse_sensor_common(
+   >dev, >notifier);
+   if (ret < 0 && ret != -ENOENT)
+   goto err_release;
+
sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
ret = media_entity_pads_init(>subdev.entity, 1, >pad);
if (ret < 0) {
@@ -1453,18 +1461,27 @@ static int et8ek8_probe(struct i2c_client *client,
goto err_mutex;
}
 
+   ret = v4l2_async_subdev_notifier_register(>subdev,
+ >notifier);
+   if (ret)
+   goto err_entity;
+
ret = v4l2_async_register_subdev(>subdev);
if (ret < 0)
-   goto err_entity;
+   goto err_async;
 
dev_dbg(dev, "initialized!\n");
 
return 0;
 
+err_async:
+   v4l2_async_notifier_unregister(>notifier);
 err_entity:
media_entity_cleanup(>subdev.entity);
 err_mutex:
mutex_destroy(>power_lock);
+err_release:
+   v4l2_async_notifier_release(>notifier);
return ret;
 }
 
@@ -1480,6 +1497,8 @@ static int __exit et8ek8_remove(struct i2c_client *client)
}
 
v4l2_device_unregister_subdev(>subdev);
+   v4l2_async_notifier_unregister(>notifier);
+   v4l2_async_notifier_release(>notifier);
device_remove_file(>dev, _attr_priv_mem);
v4l2_ctrl_handler_free(>ctrl_handler);
v4l2_async_unregister_subdev(>subdev);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature