From patchwork Thu Jan 10 15:28:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10756057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2F1291E for ; Thu, 10 Jan 2019 15:28:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9298128EF7 for ; Thu, 10 Jan 2019 15:28:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85BDC28F83; Thu, 10 Jan 2019 15:28:51 +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 25F2C28EF7 for ; Thu, 10 Jan 2019 15:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729108AbfAJP2u (ORCPT ); Thu, 10 Jan 2019 10:28:50 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36576 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727793AbfAJP2u (ORCPT ); Thu, 10 Jan 2019 10:28:50 -0500 Received: by mail-pl1-f196.google.com with SMTP id g9so5338325plo.3 for ; Thu, 10 Jan 2019 07:28:50 -0800 (PST) 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=oRLQpJfC6sZ1ksdB3sjUANiu4JbRPckOpm5gxomixO4=; b=BBu73nkJdsbYAjVMr34t4tuAZg7ImzIHLrw5Tse8SyN/Fq3h+Idog35KhXLdgjZCvq c8Gd6B480iadXsPFOgfVtb/GT5CU3CUPAywGRqskShtwcrPlhUFAh94CuNnw+1t3zauV uViHIIkvtO2/WcSWNSohSJi5LWQbHrKSvHTIY0gxiiSEeF5rGYHK6iRV1mOg+SC+zW9v q7VjwgNZb0d1RCCzU3EryIYyF/w5lUhWjQVpJn0zVuFZQRrSZME4cN5vOlfarZ1e5RIw ikDk6bJdnZr6srdv5WSjHaXSq0Kszb+HE+I51k53KzzpZ/lmvTSa+DdfSNpTPRJPirbk reZg== 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=oRLQpJfC6sZ1ksdB3sjUANiu4JbRPckOpm5gxomixO4=; b=fBHkA2OemmRah4HWthmvzeDxeZ7XEmAjTdQpUN6MvsTYdkMi47nmIr3J3u8tO8bZtE fSxSBT5Mbb6dJACrZJpb5klgGO+R8aJeDx4KD0iD+kEmnl25O7zb/JP+8DOr6csauGSW 8PXgyIuvdb+lHl7AbJjtIvnhEZ4IeCYXd/1QguQ6uxhRUdls0gTumZIzGk7xWJL86Wcy rniFCOUJkauyPfW4gOc9zwTUOu/qBOtRLWkQa3yvXxgzhuQAcPDvX3GJhopIkKVyH9wR epUUKTETaT+oLrnjEFhbQehFXc++6Om2d5DbucSr23t3lXFKw3E15+4SwIde7oPjiRPL NnEQ== X-Gm-Message-State: AJcUukcs45f6ryTliRArwOou8vA531a6J/IXTBgDbfPbTgFq/8BnS60N melK+gwhyy0V5vOL3/Fb2IbmKI2X X-Google-Smtp-Source: ALg8bN6tjmRxrjbl5MElKMQea4wQR+eVkizgCWcTg09C1eW5JUw/tl7wlH3Z2rq7MOl/gMbsbRAelw== X-Received: by 2002:a17:902:2c03:: with SMTP id m3mr10252465plb.6.1547134129778; Thu, 10 Jan 2019 07:28:49 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:25a3:d6ca:ee6b:e202]) by smtp.gmail.com with ESMTPSA id y1sm105916116pfe.9.2019.01.10.07.28.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jan 2019 07:28:49 -0800 (PST) From: Akinobu Mita To: linux-media@vger.kernel.org Cc: Akinobu Mita , Enrico Scholz , Michael Grzeschik , Marco Felsch , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH v2 1/3] media: mt9m111: make VIDIOC_SUBDEV_G_FMT ioctl work with V4L2_SUBDEV_FORMAT_TRY Date: Fri, 11 Jan 2019 00:28:27 +0900 Message-Id: <1547134109-21449-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547134109-21449-1-git-send-email-akinobu.mita@gmail.com> References: <1547134109-21449-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 The VIDIOC_SUBDEV_G_FMT ioctl for this driver doesn't recognize V4L2_SUBDEV_FORMAT_TRY and always works as if V4L2_SUBDEV_FORMAT_ACTIVE is specified. Cc: Enrico Scholz Cc: Michael Grzeschik Cc: Marco Felsch Cc: Sakari Ailus Cc: Mauro Carvalho Chehab Signed-off-by: Akinobu Mita --- * v2 - Use format->pad for the argument of v4l2_subdev_get_try_format(). drivers/media/i2c/mt9m111.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c index d639b9b..eb5bf71 100644 --- a/drivers/media/i2c/mt9m111.c +++ b/drivers/media/i2c/mt9m111.c @@ -528,6 +528,16 @@ static int mt9m111_get_fmt(struct v4l2_subdev *sd, if (format->pad) return -EINVAL; + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { +#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API + mf = v4l2_subdev_get_try_format(sd, cfg, format->pad); + format->format = *mf; + return 0; +#else + return -ENOTTY; +#endif + } + mf->width = mt9m111->width; mf->height = mt9m111->height; mf->code = mt9m111->fmt->code; @@ -1089,6 +1099,26 @@ static int mt9m111_s_stream(struct v4l2_subdev *sd, int enable) return 0; } +static int mt9m111_init_cfg(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg) +{ +#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API + struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); + struct v4l2_mbus_framefmt *format = + v4l2_subdev_get_try_format(sd, cfg, 0); + + format->width = mt9m111->width; + format->height = mt9m111->height; + format->code = mt9m111->fmt->code; + format->colorspace = mt9m111->fmt->colorspace; + format->field = V4L2_FIELD_NONE; + format->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + format->quantization = V4L2_QUANTIZATION_DEFAULT; + format->xfer_func = V4L2_XFER_FUNC_DEFAULT; +#endif + return 0; +} + static int mt9m111_g_mbus_config(struct v4l2_subdev *sd, struct v4l2_mbus_config *cfg) { @@ -1114,6 +1144,7 @@ static const struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = { }; static const struct v4l2_subdev_pad_ops mt9m111_subdev_pad_ops = { + .init_cfg = mt9m111_init_cfg, .enum_mbus_code = mt9m111_enum_mbus_code, .get_selection = mt9m111_get_selection, .set_selection = mt9m111_set_selection,