Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1427056pxb; Tue, 26 Oct 2021 08:49:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTuMrtdxRY5zg8Uts+PfHjGCR0MzdzCS4TfUaMbVEPfygtLflUkwty05aMsPCixV1sj4XE X-Received: by 2002:a17:902:ce8a:b0:140:5c8e:1ca6 with SMTP id f10-20020a170902ce8a00b001405c8e1ca6mr10507904plg.22.1635263383806; Tue, 26 Oct 2021 08:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635263383; cv=none; d=google.com; s=arc-20160816; b=TDJk/R8i5ox75FfOsp7zTarBxlqI8P6CMUlftoyONF+1EWpztmUvlFv2P305jeI97S nVEk5CZVwp1S1aaywtpPo4gJ7+FGoHEj9Wqyy0XRp02I2paDKPh67vd6MasHLsOdh950 I1NFc1I2eNVJVYTctG/wHnPQaynIuRr6/iNUgb2UF4t8kvsA9I7BdNbLkkuA2mOS1dzC hPfHQTR4C067/R1vyi3wo/41L7a+rZJonZfUHHdOc+3bDVDx9rpHA8xnmxWP/CuKa/Hg T9sDzIpJznI5VxP8tXrluJiiT8U8eL7lnTiU4w0n7cqSTp8G8+B01OPSYMc8OK/iQELh WJyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=3pJPcMK8v6oH7UZesu5cczBURYMKLJNvCzxTOSNoWHQ=; b=EIYuiMiwyLwSe32q/swqe1Y0cK8Vg65z3z7VWTBEcwWhSY1HzhZfOyG0o7Z0F4/NOl gARGvTxw8WGU/KNBHG2U5XJ7bq1GVXOamx2rtaPBxqWAJunej2rUEulBpNxKSGoAjxhb td49iy/VChKENbUIAjVUofX4X1EnolDyjXHE2XCg25l4RGyLEDgNyNqETj+shTfj23gT 2/0LALJzobyWOd3VIOHUkH7mqTtG5pRHFUp5JLQ899B4I3EBRPjzIpMEYexhsnhsr6pa I2qxWTB/G/Dmpmi8natPIYHZaSLTKYDGY5ATfCskIBguG6Ue0o6OzJB2eGIAZMXiV5/l +6TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=fLa5o+qH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id na13si1446372pjb.15.2021.10.26.08.49.31; Tue, 26 Oct 2021 08:49:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=fLa5o+qH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234938AbhJZMCI (ORCPT + 99 others); Tue, 26 Oct 2021 08:02:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbhJZMCF (ORCPT ); Tue, 26 Oct 2021 08:02:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 539C5601FC; Tue, 26 Oct 2021 11:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635249581; bh=o+N5IbGsPKkryrRuzBEiPgm3mJYskObI6+XvUx6Tjh0=; h=From:To:Cc:Subject:Date:From; b=fLa5o+qHF0NpCbB0f5KzhCXqhBqzLxKNXZO0P3n/naL4FPk5Bf42WwaLY+ak06sX9 YawG0ahpC4kT5N47xViTrFhsSd2oTHblnEFeezsypXU0nEGfAfmsI/zUwTz7RmqDkg UTdvJUKu58M2ZAkXwZDqNAaWP4ZkKI9V+wCSqsttXmsra+Pd33MH/EX5FAr0TGMn0M GxvrJL8qclWDBYeHxuyvzBpAhIsAjiAbtE5D7LcEyHvSX4+YVhi6di93mLZs35BgTB boTbYEo5rqYc4u+D6l6THg7CHa6RPa9mY6iFv4SDIBVYncz0mNYBB6Jt+Q1qjiq+2U nFcNizBDSxtUQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mfL7C-00CBtT-7P; Tue, 26 Oct 2021 12:59:38 +0100 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , "Hans de Goede" , "Nable" , "Tsuchiya Yuto" , Andy Shevchenko , Arnd Bergmann , Dan Carpenter , Greg Kroah-Hartman , Hans Verkuil , Janusz Krzysztofik , Kaixu Xia , Mauro Carvalho Chehab , Peter Zijlstra , Sakari Ailus , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH] media: atomisp: fix enum formats logic Date: Tue, 26 Oct 2021 12:59:37 +0100 Message-Id: <6ce3630152cbd9ab29e02d560c6e80fb72d0fd81.1635249567.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changeset 374d62e7aa50 ("media: v4l2-subdev: Verify v4l2_subdev_call() pad config argument") added an extra verification for a pads parameter for enum mbus format code. Such change broke atomisp, because now the V4L2 core refuses to enum MBUS formats if the state is empty. So, add .which field in order to select the active formats, in order to make it work again. While here, improve error messages. Fixes: 374d62e7aa50 ("media: v4l2-subdev: Verify v4l2_subdev_call() pad config argument") Signed-off-by: Mauro Carvalho Chehab --- .../staging/media/atomisp/pci/atomisp_ioctl.c | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 01c6eda2c3cc..03f53515ce36 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -773,7 +773,10 @@ static int atomisp_enum_fmt_cap(struct file *file, void *fh, struct video_device *vdev = video_devdata(file); struct atomisp_device *isp = video_get_drvdata(vdev); struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; - struct v4l2_subdev_mbus_code_enum code = { 0 }; + struct v4l2_subdev_mbus_code_enum code = { + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + }; + struct v4l2_subdev *camera; unsigned int i, fi = 0; int rval; @@ -783,14 +786,20 @@ static int atomisp_enum_fmt_cap(struct file *file, void *fh, return -EINVAL; } + camera = isp->inputs[asd->input_curr].camera; + if(!camera) { + dev_err(isp->dev, "%s(): camera is NULL, device is %s\n", + __func__, vdev->name); + return -EINVAL; + } + rt_mutex_lock(&isp->mutex); - rval = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, pad, - enum_mbus_code, NULL, &code); + + rval = v4l2_subdev_call(camera, pad, enum_mbus_code, NULL, &code); if (rval == -ENOIOCTLCMD) { dev_warn(isp->dev, - "enum_mbus_code pad op not supported. Please fix your sensor driver!\n"); - // rval = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, - // video, enum_mbus_fmt, 0, &code.code); + "enum_mbus_code pad op not supported by %s. Please fix your sensor driver!\n", + camera->name); } rt_mutex_unlock(&isp->mutex); @@ -820,6 +829,8 @@ static int atomisp_enum_fmt_cap(struct file *file, void *fh, f->pixelformat = format->pixelformat; return 0; } + dev_err(isp->dev, "%s(): format for code %x not found.\n", + __func__, code.code); return -EINVAL; } -- 2.31.1