From patchwork Thu Sep 14 05:11:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou.Yang@microchip.com X-Patchwork-Id: 9952445 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 C457360317 for ; Thu, 14 Sep 2017 05:24:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD20228A00 for ; Thu, 14 Sep 2017 05:24:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A178428A01; Thu, 14 Sep 2017 05:24:42 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1FAF628B58 for ; Thu, 14 Sep 2017 05:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V8V/RS2iefgoJ40b05EPGvR/R5773rDLi+oaqYwwRj0=; b=tIenm9EWOOF8ov NsjIdqmSRnhZnnmMmo+ceqw5QedcgXZuHuHu526OgRjLbB3gPWUoV7f780rbkv243og7xN7A5DQ0x EERQ3ugUdH+a35jt6yMU+z5qWW8tR/Cifm9YkKfCVfZbI00xZbLbl/4acCm7myIjD8mKWKxAxFG90 CtboJx1yUfxLt/+QHPCOpbFfOVv4mNsDRXD2tucU9C16pl6iycuk9SwyPmbThHpu/6nf3+/lLBI7L y2UQXLvs89SSntoTETlLT2rLAfODfHipnCfXYGYIYxYMRT4+sC/HIf1O8HOAHBvba0Cq2wY36r/0j aCIJuqDkUzKZV09LGAWg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dsMda-0002gB-DZ; Thu, 14 Sep 2017 05:24:30 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dsMT1-0005gq-5j for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2017 05:13:43 +0000 Received: from apsmtp01.atmel.com (10.168.254.31) by eusmtp01.atmel.com (10.145.145.31) with Microsoft SMTP Server id 14.3.235.1; Thu, 14 Sep 2017 07:12:22 +0200 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.atmel.com (10.168.254.31) with Microsoft SMTP Server id 14.3.235.1; Thu, 14 Sep 2017 13:16:46 +0800 From: Wenyou Yang To: Jonathan Corbet Subject: [PATCH v2 2/3] media: ov7670: Add the get_fmt callback Date: Thu, 14 Sep 2017 13:11:10 +0800 Message-ID: <20170914051111.18197-3-wenyou.yang@microchip.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170914051111.18197-1-wenyou.yang@microchip.com> References: <20170914051111.18197-1-wenyou.yang@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170913_221336_317599_06E3AF5C X-CRM114-Status: UNSURE ( 9.32 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wenyou Yang , linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, Linux Media Mailing List Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add the get_fmt callback, also enable V4L2_SUBDEV_FL_HAS_DEVNODE flag to make this subdev has device node. Signed-off-by: Wenyou Yang --- Changes in v2: None drivers/media/i2c/ov7670.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index 5c8460ee65c3..efc738112e2a 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -230,6 +230,7 @@ struct ov7670_info { struct v4l2_ctrl *saturation; struct v4l2_ctrl *hue; }; + struct v4l2_mbus_framefmt format; struct ov7670_format_struct *fmt; /* Current format */ struct clk *clk; struct gpio_desc *resetb_gpio; @@ -973,6 +974,29 @@ static int ov7670_try_fmt_internal(struct v4l2_subdev *sd, fmt->width = wsize->width; fmt->height = wsize->height; fmt->colorspace = ov7670_formats[index].colorspace; + + info->format.code = fmt->code; + info->format.width = fmt->width; + info->format.height = fmt->height; + info->format.colorspace = fmt->colorspace; + + return 0; +} + +static int ov7670_get_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *format) +{ + struct ov7670_info *info = to_state(sd); + struct v4l2_mbus_framefmt *fmt; + + if (format->which == V4L2_SUBDEV_FORMAT_TRY) + fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad); + else + fmt = &info->format; + + format->format = *fmt; + return 0; } @@ -1526,6 +1550,7 @@ static const struct v4l2_subdev_pad_ops ov7670_pad_ops = { .enum_frame_interval = ov7670_enum_frame_interval, .enum_frame_size = ov7670_enum_frame_size, .enum_mbus_code = ov7670_enum_mbus_code, + .get_fmt = ov7670_get_fmt, .set_fmt = ov7670_set_fmt, }; @@ -1698,6 +1723,7 @@ static int ov7670_probe(struct i2c_client *client, v4l2_ctrl_handler_setup(&info->hdl); + info->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; ret = v4l2_async_register_subdev(&info->sd); if (ret < 0) goto entity_cleanup;