From patchwork Mon Sep 11 13:18:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 9947411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 58B26603F3 for ; Mon, 11 Sep 2017 13:18:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C2012896D for ; Mon, 11 Sep 2017 13:18:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FC3928560; Mon, 11 Sep 2017 13:18:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AA7A28560 for ; Mon, 11 Sep 2017 13:18:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751956AbdIKNSf (ORCPT ); Mon, 11 Sep 2017 09:18:35 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:58961 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbdIKNSe (ORCPT ); Mon, 11 Sep 2017 09:18:34 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 24CC4824E2; Mon, 11 Sep 2017 15:18:32 +0200 (CEST) Date: Mon, 11 Sep 2017 15:18:31 +0200 From: Pavel Machek To: Sakari Ailus Cc: linux-media@vger.kernel.org, niklas.soderlund@ragnatech.se, robh@kernel.org, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, linux-acpi@vger.kernel.org, mika.westerberg@intel.com, devicetree@vger.kernel.org, sre@kernel.org Subject: [PATCH] et8ek8: Add support for flash and lens devices Message-ID: <20170911131831.GA12658@amd> References: <20170908131235.30294-1-sakari.ailus@linux.intel.com> <20170908131822.31020-18-sakari.ailus@linux.intel.com> <20170909214724.GA18677@amd> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170909214724.GA18677@amd> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 = &et8ek8_internal_ops; + ret = v4l2_fwnode_reference_parse_sensor_common( + &client->dev, &sensor->notifier); + if (ret < 0 && ret != -ENOENT) + goto err_release; + sensor->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_pads_init(&sensor->subdev.entity, 1, &sensor->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(&sensor->subdev, + &sensor->notifier); + if (ret) + goto err_entity; + ret = v4l2_async_register_subdev(&sensor->subdev); if (ret < 0) - goto err_entity; + goto err_async; dev_dbg(dev, "initialized!\n"); return 0; +err_async: + v4l2_async_notifier_unregister(&sensor->notifier); err_entity: media_entity_cleanup(&sensor->subdev.entity); err_mutex: mutex_destroy(&sensor->power_lock); +err_release: + v4l2_async_notifier_release(&sensor->notifier); return ret; } @@ -1480,6 +1497,8 @@ static int __exit et8ek8_remove(struct i2c_client *client) } v4l2_device_unregister_subdev(&sensor->subdev); + v4l2_async_notifier_unregister(&sensor->notifier); + v4l2_async_notifier_release(&sensor->notifier); device_remove_file(&client->dev, &dev_attr_priv_mem); v4l2_ctrl_handler_free(&sensor->ctrl_handler); v4l2_async_unregister_subdev(&sensor->subdev);