Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp193977lqg; Wed, 10 Apr 2024 22:35:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUYTuSoK8f4Fvo6F4OsAXgRdsOzJvLalpfUK/8oYw2cM2n3jSaUEEcD6mSpgNdgQJFDOlYVdOS19jrYq362IyuJCDAASdHZ3WvQMNWzrg== X-Google-Smtp-Source: AGHT+IE6t2ES4NsTOU9QKuRUjfFFzSsTu3VQ1HM6I3us6XrI4qm4wuP0O/ukKZA6K7KhhZ586jK2 X-Received: by 2002:a05:622a:5cc:b0:432:ffa8:19ac with SMTP id d12-20020a05622a05cc00b00432ffa819acmr5450096qtb.55.1712813707566; Wed, 10 Apr 2024 22:35:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712813707; cv=pass; d=google.com; s=arc-20160816; b=GwJf7UfyEt6vP4DPZsM8WYDQMOl1EQN0NSDTUfemQQKAJGDX6f39+8tzC2ztfgxujQ Wfq/2qb9tTfIxGK1vtkdVFw1Fl4hjgGzbJpdVaVz7rTyG+qee47K9KPs8Ih955uWcLyc 8LuP6OPG+3PP1SO6xtsowr9pRwiSHDy2AwVgDDLTsz6L1cwPvf9sEjEv6hxJfDmD+9Fm PYsv0SDZ0zt7bCSYhyEsPpze5ATzQ6jerCaOmEebmdL6opG+J4ledmREbY2Fqo+ty26p oFN8YtxC0x4sQvMduidv3bDnpIeA+YXvWlFIxF4bwPnsxUgfZoMJmWrI6ebAwsqymyFc vGeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=7Nghq2Pu9HZF08MyXI/ZTAKeDAMHEtDXGtvDpGCqges=; fh=Lk00RAwXfEdrvl02y/oikuAjnGx1DnhK+LC4UHSvN80=; b=qUSoKYPimXj7nBYNgViF3KIZPRsEN4Td6u4NSHVeZTb1NWOgefvN89kZz4pUNulL8w U7uYNIT6XEcCzVPCU5Vk92FjOsqx22oXZkLVBIfyf/15chBS3PlKvQjhJxcpI6B8EZqj UUjzCBAjY5ecHc2e/WD6DXnfOf06jBd8yHuLXWD1AJuqSZiaAHp2SGd6VFzYn870DJ+6 cKe98BFKDTdifizHcBw5p5ecFsO5Wp/EhRt+CdqCPZyDrGWyIDDU0clJLizphDuvclkD M9vurHryBQGDlgMONxLrWONBbimkTMe0VoAivxscJkO1sY6cnDnbHdYR+YLMYlqzUL0f yw/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=gETIcwS7; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-139792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139792-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v2-20020a05622a130200b0043478a6854bsi874074qtk.46.2024.04.10.22.35.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 22:35:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=gETIcwS7; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-139792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139792-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4C5741C211B6 for ; Thu, 11 Apr 2024 05:35:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6D4F13C9D1; Thu, 11 Apr 2024 05:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gETIcwS7" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 549D813B7AA; Thu, 11 Apr 2024 05:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712813698; cv=none; b=rgQJV/gqyFRKVewrc7ef9lg8Szpy3FHtDwJw9OuN1am87qSwAjYPFC/LuDx4p9/Gz9PlzR2DVDAev0BxMcwVh5Aqf2oXuHHbgwFrZgVMPueasttDKGBsP8obX9fWC3V9HPXvsEkUP4A8cjB8f53wjtmfQCisouFF8voZCpmqu9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712813698; c=relaxed/simple; bh=YZ7Giok5JN6R5bpF506pLqpTxbEu6Kz+yRugyUgyUpA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WxdBEmcbGPA42g7dTAEHPa/NLJroKfdq6QjOhnuU0qPQGzbir8aMQs61/Jr+GJvXEDJmPSII9TW85VqxG1phrskgPSp9zU1bPVTFIKdsnKpwEv65pF7OtgruBEOadeu9xZOcbohWvaT+0hCgCZPOIMYHupHXErbEdjNVezcbGdw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=gETIcwS7; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from [192.168.1.108] (unknown [103.86.18.224]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D5594E1; Thu, 11 Apr 2024 07:34:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712813652; bh=YZ7Giok5JN6R5bpF506pLqpTxbEu6Kz+yRugyUgyUpA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gETIcwS7cuAoyT9gLx+IT+h3ZPAFjifl8I3yYbv2F/Z0JFKdA3Va3UkGCgAdZWOG+ l/ex/2OvOc482/mP+srMYm6KALPugS5uyYAwN4TorgRV6oRL+X1T45FxFbPky6wuRK cX1BYt8i/ZnJFE2aO1ucI+c2SUnup3Kbb5cCaIrg= Message-ID: <397c3723-2100-4717-9206-d53e71eae885@ideasonboard.com> Date: Thu, 11 Apr 2024 11:04:47 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/9] media: subdev: Add checks for subdev features Content-Language: en-US To: Tomi Valkeinen , Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240410-enable-streams-impro-v3-0-e5e7a5da7420@ideasonboard.com> <20240410-enable-streams-impro-v3-3-e5e7a5da7420@ideasonboard.com> From: Umang Jain In-Reply-To: <20240410-enable-streams-impro-v3-3-e5e7a5da7420@ideasonboard.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Tomi, On 10/04/24 6:05 pm, Tomi Valkeinen wrote: > Add some checks to verify that the subdev driver implements required > features. > > A subdevice that supports streams (V4L2_SUBDEV_FL_STREAMS) must do one > of the following: > > - Implement neither .enable/disable_streams() nor .s_stream(), if the > subdev is part of a video driver that uses an internal method to > enable the subdev. > - Implement only .enable/disable_streams(), if support for legacy > sink-side subdevices is not needed. > - Implement .enable/disable_streams() and .s_stream(), if support for > legacy sink-side subdevices is needed. > > At the moment the framework doesn't check this requirement. Add the > check. > > Signed-off-by: Tomi Valkeinen The code looks aligned with the restrictions mentioned in the commit message. Only one question in case 3), does the .s_stream() needs to be helper function I think, can we (or do we) need to check that as well? Reviewed-by: Umang Jain > --- > drivers/media/v4l2-core/v4l2-subdev.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > index 4a531c2b16c4..606a909cd778 100644 > --- a/drivers/media/v4l2-core/v4l2-subdev.c > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > @@ -1533,6 +1533,33 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, > struct lock_class_key *key) > { > struct v4l2_subdev_state *state; > + struct device *dev = sd->dev; > + bool has_disable_streams; > + bool has_enable_streams; > + bool has_s_stream; > + > + /* Check that the subdevice implements the required features */ > + > + has_s_stream = v4l2_subdev_has_op(sd, video, s_stream); > + has_enable_streams = v4l2_subdev_has_op(sd, pad, enable_streams); > + has_disable_streams = v4l2_subdev_has_op(sd, pad, disable_streams); > + > + if (has_enable_streams != has_disable_streams) { > + dev_err(dev, > + "subdev '%s' must implement both or neither of .enable_streams() and .disable_streams()\n", > + sd->name); > + return -EINVAL; > + } > + > + if (sd->flags & V4L2_SUBDEV_FL_STREAMS) { > + if (has_s_stream && !has_enable_streams) { > + dev_err(dev, > + "subdev '%s' must implement .enable/disable_streams()\n", > + sd->name); > + > + return -EINVAL; > + } > + } > > state = __v4l2_subdev_state_alloc(sd, name, key); > if (IS_ERR(state)) >