Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp82318lqp; Fri, 12 Apr 2024 11:02:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIY3F5lzqpJ/9+mYE/MY7lhYToRNlOcc7S6Fzpj71WEHvIY1iIzCa1ZX/FugzJ23EdDTrqX2up9dNM1wQkP6vHgnWjICZPZRIlOXctGg== X-Google-Smtp-Source: AGHT+IHMMxAkAIPyy9aJ2Pf9byo4weGRrbiT3UwbGKjOtQRL4QAKnhmgIPJNv/2lqxBrNuwAE/uM X-Received: by 2002:a05:6a20:5609:b0:1a5:bc18:97d8 with SMTP id ir9-20020a056a20560900b001a5bc1897d8mr3274211pzc.3.1712944978468; Fri, 12 Apr 2024 11:02:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712944978; cv=pass; d=google.com; s=arc-20160816; b=qO8KikpyVP0uRbfpnRvxqSQq2aPQTgZQeHTgsbD+aDUDiKNhBgPuw8rUII04MDYDPX 6THLKkEPPSDOBHTqfKeUuVuMEJDiqzm2DQ4ftrI/BZZ3Bg5eZKiBrU4wV6eoTKSfenel 7q4r68NZjDB/dumsPACbf/3Jp6GbMS6Dg2sbecP9ujqGlUaqcunMUe9UwVqoNITYTuHV BX+uy26AwnDH35A+gaEwIVqy/su7lNed2XyZxOsClREYsDZNNMDgETArrZIH8MACAbAa u4lnRsrlZMmzUam1a9jMI/kagSu7b8LomgeyGKCxBwBDF9z4IhbCFllhIve5rYFuQlSx G5bQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=clVvF1Osoo5CP2Vl/m9Bq2xtERFsWjrHlIzAecshm2o=; fh=kb24mPs25WqywxJHooszEmv14QS87Sk+hEKpHxhz2LM=; b=Uxeekzfll1D6n05t30IyGTEY0SpZxYUIgGTW0bdGJLYoM2LMWNCUVyWyTw5ij2n8SI gUSNL0nVCsJSuylHiAm5XFfWNXF9XDB7BeBMUWi4YMyeAoQfGJeUjBnPVU82yq8drYcy z5sMliWl9u9yw+Pemo6izrH3Q5zBnOzA9T2QoKc1Oy14tbmbSsJZtdg/QoFOOS6DTq3E o261O8+s0sbeBqqCuTyVOIWi7y9QSMN3m22Ah6XYnOBIlnXYCt65rn/h2u/GUGKbUMCh JmECUUw9zXXM3bjYHxZeGEkdMuwa7tFUKLOO7Qq7D/CGn7H0q3Exej8Q9ug9+3E+QDqP iE8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=A+J8s0Ka; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-143147-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143147-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s68-20020a625e47000000b006ed4fd36aebsi3707982pfb.196.2024.04.12.11.02.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 11:02:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143147-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=A+J8s0Ka; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-143147-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143147-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C63372841A3 for ; Fri, 12 Apr 2024 17:42:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24F3C14E2D7; Fri, 12 Apr 2024 17:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="A+J8s0Ka" 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 EC02314C587; Fri, 12 Apr 2024 17:41:54 +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=1712943716; cv=none; b=eCW6pE0CBuMREdMCzPKAULum5/s6qPXu+diQRM6ZDcoN6slPwHddlapqd66esZgSES9AYIypHThf33DK2zCRLKtS01k16WLlo/IKCYYuo0qiWdRT+rVBFQX0IDAgEfK8udQ3j6RABWfFRtP6P5N/l+m11w69/oEIMgE7t4ddfzg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712943716; c=relaxed/simple; bh=lq6CAvGdg2Fkl3PAyGSZcvBPOat6xJoMsfeERKMfvuQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X1AxWIcewL0yEnHGSbfzOTuR3MHYiAv6DbymDXMlk3aV92YWddv3qwK88LqsHRSzX81nBVLJ2QNMgYqB/XIAsSW1sRsQJIYEdWaR6ZxXnicfdinMBqspt6dfKI4sg6r7mrFO6s+zwIhTXt2t0RIt09pIA33SDsNyp4nFSg6zZaw= 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=A+J8s0Ka; 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 pendragon.ideasonboard.com (85-76-65-73-nat.elisa-mobile.fi [85.76.65.73]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 68A798E1; Fri, 12 Apr 2024 19:41:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712943669; bh=lq6CAvGdg2Fkl3PAyGSZcvBPOat6xJoMsfeERKMfvuQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A+J8s0Kab24QyO/W/9GIASpOo0h9l9jx9HrvD/0ygNRPDigJcQlNicmmYP5YJIfi+ +GUlGiujFoKMrODHwcGFcj4thyH3ZqcATJm6bB/GBS/5QW6Xfej+S8p7f5eJDvdEmk uRJDFMUVwi9HwCyx6lZGMoZnZAmC6HtHH0IMEZZI= Date: Fri, 12 Apr 2024 20:41:43 +0300 From: Laurent Pinchart To: Tomi Valkeinen Cc: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Umang Jain , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/9] media: subdev: Add checks for subdev features Message-ID: <20240412174143.GF31122@pendragon.ideasonboard.com> References: <20240410-enable-streams-impro-v3-0-e5e7a5da7420@ideasonboard.com> <20240410-enable-streams-impro-v3-3-e5e7a5da7420@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240410-enable-streams-impro-v3-3-e5e7a5da7420@ideasonboard.com> Hi Tomi, Thank you for the patch. On Wed, Apr 10, 2024 at 03:35:50PM +0300, 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 Reviewed-by: Laurent Pinchart > --- > 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)) > -- Regards, Laurent Pinchart