Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9334CCDB465 for ; Mon, 16 Oct 2023 10:21:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232090AbjJPKVx (ORCPT ); Mon, 16 Oct 2023 06:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230090AbjJPKVw (ORCPT ); Mon, 16 Oct 2023 06:21:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07401B4 for ; Mon, 16 Oct 2023 03:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697451710; x=1728987710; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=77WYDDHliirvKq+pEFu+/jhd0KTcJWN2qNVk2yUZoC0=; b=jQg0UwJpBRk7xVEek4P0f6VAYVfly3ZWgYPxc+FzsfLFh4g8xp4bQe0a 6s9sv54rmFMLJ7q5ueDb5MWhXYSN5XO0hNXmtcjUo85nkQlfJ/LRetVPl ISDZb5T1SWguZb81YPcok9SKyP+5hP1ds7IHYe3E5nr0+D9jBF7LbKt7m 1e0BedpQEEpqYAQD7NadSc7oy2b7NN4s2kGT/CzenO9w2IbyydtiLy+or aeg9SVo9LulwzkJNnGEEU9+S4CziQXemi4pAw7OUOkwopwfsDMZbPDtar Lpq3+1RLQBTe7XbqimOM7ok/yfyUYjYZgtvgeKH/Bsgw5uJtwuEQkwnMP Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="416562133" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="416562133" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 03:21:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10863"; a="1002880295" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1002880295" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 03:21:48 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id D1ECC11F82E; Mon, 16 Oct 2023 13:21:45 +0300 (EEST) Date: Mon, 16 Oct 2023 10:21:45 +0000 From: Sakari Ailus To: Laurent Pinchart Cc: linux-media@vger.kernel.org, hverkuil@xs4all.nl, tomi.valkeinen@ideasonboard.com, jacopo.mondi@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com Subject: Re: [PATCH 2/6] media: v4l: subdev: Also return pads array information on stream functions Message-ID: References: <20231013104424.404768-1-sakari.ailus@linux.intel.com> <20231013104424.404768-3-sakari.ailus@linux.intel.com> <20231013110741.GD11101@pendragon.ideasonboard.com> <20231016082452.GH23177@pendragon.ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On Mon, Oct 16, 2023 at 08:59:15AM +0000, Sakari Ailus wrote: > On Mon, Oct 16, 2023 at 11:24:52AM +0300, Laurent Pinchart wrote: > > Hi Sakari, > > > > On Fri, Oct 13, 2023 at 11:13:00AM +0000, Sakari Ailus wrote: > > > On Fri, Oct 13, 2023 at 02:07:41PM +0300, Laurent Pinchart wrote: > > > > On Fri, Oct 13, 2023 at 01:44:20PM +0300, Sakari Ailus wrote: > > > > > There are two sets of functions that return information from sub-device > > > > > state, one for stream-unaware users and another for stream-aware users. > > > > > Add support for stream-aware functions to return format, crop and compose > > > > > information from pad-based array that are functionally equivalent to the > > > > > old, stream-unaware ones. > > > > > > > > > > Also check state is non-NULL, in order to guard against old drivers > > > > > potentially calling this with NULL state for active formats or selection > > > > > rectangles. > > > > > > > > I'm not too keen on this I'm afraid :-( I think it gets confusing for > > > > drivers that are not stream-aware to have to call a function that takes > > > > a stream number. I don't see a problem with keeping two different sets > > > > of functions, one for stream-aware drivers, and one for other drivers. > > > > > > This becomes a nuisance in drivers such as CCS that work with sub-devices > > > some of which have streams and others which don't. I don't see why we > > > should have two sets of functions to access the same information, even > > > though it's stored differently. > > > > > > I can add a wrapper using C11 _Generic to make the stream number go away. > > > > That could possibly be interesting. > > I'll add this for v2. C11 _Generic() isn't up to the task as it only deals with argument types. On the other hand, variadic arguments supports this. It'll look like: #define v4l2_subdev_get_crop(state, pad, ...) \ __v4l2_subdev_get_crop_ ## __VA_OPT__(stream) \ (state, pad __VA_OPT__(,) __VA_ARGS__) #define __v4l2_subdev_get_crop_(state, pad) \ __v4l2_subdev_get_crop(state, pad, 0) #define __v4l2_subdev_get_crop_stream(state, pad, stream) \ __v4l2_subdev_get_crop(state, pad, stream) struct v4l2_rect * __v4l2_subdev_get_crop(struct v4l2_subdev_state *state, unsigned int pad, u32 stream); Which I'd say is tolerable, given the result is a single function to access format, crop and compose information in the sub-device state. Any thoughts on this? -- Sakari Ailus