From patchwork Thu Oct 12 16:21:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10002309 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 33BE860216 for ; Thu, 12 Oct 2017 16:21:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2477D28DE9 for ; Thu, 12 Oct 2017 16:21:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18F0728E12; Thu, 12 Oct 2017 16:21:59 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 B242A28DE9 for ; Thu, 12 Oct 2017 16:21:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753037AbdJLQV5 (ORCPT ); Thu, 12 Oct 2017 12:21:57 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:49884 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752899AbdJLQV5 (ORCPT ); Thu, 12 Oct 2017 12:21:57 -0400 Received: by mail-pf0-f193.google.com with SMTP id l188so5541872pfc.6 for ; Thu, 12 Oct 2017 09:21:56 -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=709QWyoyzISQenkYKAtfi8OM9O6pulEPTYyfgeQd7sg=; b=oQRKJsBBfKZgPpb+EOUvkkm0N2m3hnMQszx6PciqrLY5krwiuKHB04EjftP7mkrhhv qxn55E4va8ohGFGQUF83RNV82CpFVmXYh9+fRsDWY+rvs2tSpzoP1l9h+Wix/x3EUcoB H9s/KOneX5RFvSXTuzUTseUvgmOd9g0LyiPaDqZjlbnDcyxCRaNFJ7636MnB+EP+OeTU 5m6R50USyEM5732okiM5hpRf6LvfsQ6AU1bE4+Fd+YgM0weu1j+1IAlndb+iI2hUUWeJ uBanQXDgWQ4oPP0/eavZxu7U6MlXZ1xyoVfi+VPwehlMJhUJsrhSQtXbmy+Ffr2OsFWZ 1pxA== 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=709QWyoyzISQenkYKAtfi8OM9O6pulEPTYyfgeQd7sg=; b=nGKm1IbuzJMauVIKLVinLockx9mizutxf8cGw6LbJmSicPybsNEDZZdZCsfAZqdWbW UGYDxxKFg8vz94SxjfefmFUWKmZJ/fmH0Jaupr30a+mVITnvwwBIF9jwHg3qFZzwT/oV 9z+nJxAqVZFdQybGQ93smlMBmMK2/SzDA06bjqx6CY1gOJ3zllUJTBK0CJ/RyZMLoOUm FHi+gLIJcsxByTW5ZRANPKpgqwQ1ad15dtUwbbGZ9F6n6CEDn3w2ovBpN+76v7EQMJQb W5734+qSIuY3rBIkXbb2P2KoO7maXnPj89Bum6wAjQwoP5IBB902gSvFv+NQCP4uFngN GSDw== X-Gm-Message-State: AMCzsaXmnHSDzLcR06pfVmcnWh3Bw64lAxTCKnphNl4V73DynkteidOh M/U8UFPJTQcIWmy2+P9z5Z2yhQ== X-Google-Smtp-Source: AOwi7QCWHLfk/s0bFDR7LHnV2rNqfpisQEzVfLqc1j9O29JH0nSkjMpGZFXH2yABtQQwIJE3fu1A8w== X-Received: by 10.98.74.93 with SMTP id x90mr2630542pfa.177.1507825316441; Thu, 12 Oct 2017 09:21:56 -0700 (PDT) Received: from mita-ThinkPad-T540p.lan ([240f:4:c2bc:1:ec18:f5a1:1d8f:bb9f]) by smtp.gmail.com with ESMTPSA id x11sm27404438pgq.29.2017.10.12.09.21.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 09:21:55 -0700 (PDT) From: Akinobu Mita To: linux-media@vger.kernel.org Cc: Akinobu Mita , Jonathan Corbet , Mauro Carvalho Chehab Subject: [PATCH 4/4] media: ov7670: add get_fmt() pad ops callback Date: Fri, 13 Oct 2017 01:21:17 +0900 Message-Id: <1507825277-18364-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507825277-18364-1-git-send-email-akinobu.mita@gmail.com> References: <1507825277-18364-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 This enables to print the current format on the source pad of the ov7670 subdev by media-ctl. Cc: Jonathan Corbet Cc: Mauro Carvalho Chehab Signed-off-by: Akinobu Mita --- drivers/media/i2c/ov7670.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index 38e1876..9fe99c5 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -234,6 +234,7 @@ struct ov7670_info { struct v4l2_ctrl *hue; }; struct ov7670_format_struct *fmt; /* Current format */ + struct ov7670_win_size *wsize; /* Current format */ struct clk *clk; struct gpio_desc *resetb_gpio; struct gpio_desc *pwdn_gpio; @@ -875,6 +876,36 @@ static int ov7670_set_framerate_legacy(struct v4l2_subdev *sd, return ov7670_write(sd, REG_CLKRC, info->clkrc); } +static int ov7670_get_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *fmt) +{ + struct ov7670_info *info = to_state(sd); + + if (fmt->pad) + return -EINVAL; + + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API + struct v4l2_mbus_framefmt *mf; + + mf = v4l2_subdev_get_try_format(sd, cfg, 0); + fmt->format = *mf; + return 0; +#else + return -ENOTTY; +#endif + } + + fmt->format.colorspace = info->fmt->colorspace; + fmt->format.code = info->fmt->mbus_code; + fmt->format.field = V4L2_FIELD_NONE; + fmt->format.width = info->wsize->width; + fmt->format.height = info->wsize->height; + + return 0; +} + /* * Store a set of start/stop values into the camera. */ @@ -1026,6 +1057,7 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd, if (wsize->regs) ret = ov7670_write_array(sd, wsize->regs); info->fmt = ovfmt; + info->wsize = wsize; /* * If we're running RGB565, we must rewrite clkrc after setting @@ -1529,6 +1561,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, }; @@ -1647,6 +1680,7 @@ static int ov7670_probe(struct i2c_client *client, info->devtype = &ov7670_devdata[id->driver_data]; info->fmt = &ov7670_formats[0]; + info->wsize = &info->devtype->win_sizes[0]; info->clkrc = 0; /* Set default frame rate to 30 fps */