From patchwork Sat Apr 7 15:48:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10327893 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 3C10B60541 for ; Sat, 7 Apr 2018 15:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C86C2951C for ; Sat, 7 Apr 2018 15:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 211E029529; Sat, 7 Apr 2018 15:48:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 B6A342951C for ; Sat, 7 Apr 2018 15:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751804AbeDGPsw (ORCPT ); Sat, 7 Apr 2018 11:48:52 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:38495 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751741AbeDGPsu (ORCPT ); Sat, 7 Apr 2018 11:48:50 -0400 Received: by mail-pf0-f194.google.com with SMTP id y69so2876252pfb.5; Sat, 07 Apr 2018 08:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OfFOFLOsVDQO0o9bghvNZPWlShOddzkgnMOwI4/D8LQ=; b=LdFZ/w/lBqV5DR60qdjC4BIZ91ujjP0xDRL/WtaDIS5/El0mqdIDKOhM+z+swsRTr4 39e9fITMGpFfmkybWWzeQqEkfdgvEwsj87P4X+XNdy/9yd/Wqwz1EUslijYN0Lo9vIZh At4kAii23M2r3pmTuwrzdIsO2afxX86EVLRf1lEkML08ttzdSmx9Hbe+KLs7nHtUFZnP m556j0blHHnnm6Q030j5DpmlbJWUgUrDbRIZ8Ba9+GSTDYzKUK4BzukBs4GoEwNTDVuD u5eRPg3vrF2iL29ErBnQn4lhlsvuKmi1LGe67eRpnLSQ1rreqKWfNsGIILx2QpcsuLiP h6/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OfFOFLOsVDQO0o9bghvNZPWlShOddzkgnMOwI4/D8LQ=; b=ejKM50j/WQxTS4y3+74ab+Rz2lwTshmSMko7tdpOWpxr8n3eedlpNxRlQeS7m0nVuo HASX0B3WVBGUSvXaF/wLpStscsufHFqL0eHoc/xibbLygqn0BfbKV1cVuby+1arV4lON A9ePm0tjpZgBH697CvkNSRzHwMcq5e0Ifu81OIpOK6JQW0lgTQEkmlNR3qfeReEEfjqh OKsEsDt+ZL3hH0Bn5ziL9dQu0DPw9ChpgYkd5eorjdCKBxsoxp4ek1mm/GtDhq/tKtj5 YOcy8IM9mXQadsVZRQcivWkmdD95cP1+juAMqXFsYwgLm7ufHN0n2mmGAaPkZOnWMMmp CHsg== X-Gm-Message-State: AElRT7HyETJnzbLv9h/T5uxAk6qVFWb44LGTxUKx5tTCpEbazMVVxFMh 18ScNWueTc8HAf2krVMTDEGWlA== X-Google-Smtp-Source: AIpwx498ekeMZATYwGyoMJYwLIRsHSVqy5PcMPxy9hYjxZOOuhcFBR/yEZv2eNrq34HpY4Y6MdJszw== X-Received: by 10.99.170.9 with SMTP id e9mr20431765pgf.331.1523116130299; Sat, 07 Apr 2018 08:48:50 -0700 (PDT) Received: from localhost.localdomain ([240f:4:c2bc:1:3c69:7d24:eba0:888]) by smtp.gmail.com with ESMTPSA id x14sm23536871pgo.82.2018.04.07.08.48.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 07 Apr 2018 08:48:49 -0700 (PDT) From: Akinobu Mita To: linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: Akinobu Mita , Jacopo Mondi , Laurent Pinchart , Hans Verkuil , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 4/6] media: ov772x: add media controller support Date: Sun, 8 Apr 2018 00:48:08 +0900 Message-Id: <1523116090-13101-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523116090-13101-1-git-send-email-akinobu.mita@gmail.com> References: <1523116090-13101-1-git-send-email-akinobu.mita@gmail.com> 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 Create a source pad and set the media controller type to the sensor. Cc: Jacopo Mondi Cc: Laurent Pinchart Cc: Hans Verkuil Cc: Sakari Ailus Cc: Mauro Carvalho Chehab Signed-off-by: Akinobu Mita --- drivers/media/i2c/ov772x.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c index 4bb81ff..5e91fa1 100644 --- a/drivers/media/i2c/ov772x.c +++ b/drivers/media/i2c/ov772x.c @@ -425,6 +425,9 @@ struct ov772x_priv { unsigned short band_filter; unsigned int fps; int (*reg_read)(struct i2c_client *client, u8 addr); +#ifdef CONFIG_MEDIA_CONTROLLER + struct media_pad pad; +#endif }; /* @@ -1328,9 +1331,17 @@ static int ov772x_probe(struct i2c_client *client, goto error_clk_put; } - ret = ov772x_video_probe(priv); +#ifdef CONFIG_MEDIA_CONTROLLER + priv->pad.flags = MEDIA_PAD_FL_SOURCE; + priv->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR; + ret = media_entity_pads_init(&priv->subdev.entity, 1, &priv->pad); if (ret < 0) goto error_gpio_put; +#endif + + ret = ov772x_video_probe(priv); + if (ret < 0) + goto error_entity_cleanup; priv->cfmt = &ov772x_cfmts[0]; priv->win = &ov772x_win_sizes[0]; @@ -1338,11 +1349,15 @@ static int ov772x_probe(struct i2c_client *client, ret = v4l2_async_register_subdev(&priv->subdev); if (ret) - goto error_gpio_put; + goto error_entity_cleanup; return 0; +error_entity_cleanup: +#ifdef CONFIG_MEDIA_CONTROLLER + media_entity_cleanup(&priv->subdev.entity); error_gpio_put: +#endif if (priv->pwdn_gpio) gpiod_put(priv->pwdn_gpio); error_clk_put: @@ -1357,6 +1372,9 @@ static int ov772x_remove(struct i2c_client *client) { struct ov772x_priv *priv = to_ov772x(i2c_get_clientdata(client)); +#ifdef CONFIG_MEDIA_CONTROLLER + media_entity_cleanup(&priv->subdev.entity); +#endif clk_put(priv->clk); if (priv->pwdn_gpio) gpiod_put(priv->pwdn_gpio);