Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2812670rwd; Wed, 14 Jun 2023 07:39:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5h84b3MGnq6hpceb/adlFmJ4Lsn/P/FlDSmtxCz39voXR94m4vGxjfTRDlmm8IahsSfKNs X-Received: by 2002:a05:6a00:174e:b0:64b:205:dbf3 with SMTP id j14-20020a056a00174e00b0064b0205dbf3mr2908204pfc.34.1686753569468; Wed, 14 Jun 2023 07:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686753569; cv=none; d=google.com; s=arc-20160816; b=KFU1vG4fUDAuwAxwwkqXSl7bw178LWZyyAOMzPsSLdi4kVbL8jYdONqHVhAdYvZgDL ZtCh1awHAJRerVNeEld35cLxTmmenrFE09Gbq9nP7K9LKAzOZXMRiY+RbRflspFwRxY4 qP9HSkvLq24lQ9CGzPV/hdtJqtf3W4qZp4CtIEV3L+ycMrowELa9kbRqeezT1msYrLq6 qnUiZ87xeYkmYjYqZM2c964tc5qnSdqaXHG9foaa9qKslavTvuNTZmGY3OAY4N/XwsWX A4y9GGxyswCK20tMO+yT5dieFCE/6ziULFi9weKwHaxYKI1jN5HWcuhu2RZwa4XwOW2S fZZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=yImfhC8AR4xKOcBgtOU85aVTV3useXUT8px2TRzHvk8=; b=qt28+YJaHeXWGCudHtUc+8ega0QzHmxHFQfHdgishKg3O6ljHg/jSF7HhLm98CIfNg 0Fjj6pRJR8/uNOS9UsGMlcfbM86TKFL9IDUGETqjStmqBAc+jceSp96TEJudpJG1XTvK UYwfV3MLqFGsDaNMeOIw53RQoOvVptWAutwabRwpo0KqWlbdXZ9V+YJwzbiQFhFwniGn 5EuwHnaa9WxrR7v5RZE1Bdkfmz2sqgvrVFGUqG2OCJ67m55Nntry7yUH+Li3yr7MQEbl kaby/Bmrh7JLtbB3ZW5tB3V8TWJOYC9p4uav7SYGhEl9Fdli0b4UtMX3E21YHCvBvpNK 89Jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a63b254000000b005348c9eeec8si11282050pgo.570.2023.06.14.07.39.16; Wed, 14 Jun 2023 07:39:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245053AbjFNNnu (ORCPT + 99 others); Wed, 14 Jun 2023 09:43:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245049AbjFNNnr (ORCPT ); Wed, 14 Jun 2023 09:43:47 -0400 Received: from mx.gpxsee.org (mx.gpxsee.org [37.205.14.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 935891BFD; Wed, 14 Jun 2023 06:43:44 -0700 (PDT) Received: from [192.168.4.25] (unknown [62.77.71.229]) by mx.gpxsee.org (Postfix) with ESMTPSA id 7B677E463; Wed, 14 Jun 2023 15:43:42 +0200 (CEST) Message-ID: Date: Wed, 14 Jun 2023 15:43:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [RESEND PATCH v6 1/1] Added Digiteq Automotive MGB4 driver Content-Language: en-US To: Hans Verkuil , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Martin_T=c5=afma?= References: <20230524112126.2242-1-tumic@gpxsee.org> <20230524112126.2242-2-tumic@gpxsee.org> <3a7da3cd-8d03-a2c4-0534-a75565aefc13@xs4all.nl> <7072a8f3-5c9e-1170-e480-6fb57b95110f@gpxsee.org> <6b792de3-bb2c-d2b5-a652-eca6d20dad20@xs4all.nl> <089e728b-0596-d3e3-39a1-651a3ac73e33@xs4all.nl> <72494a61-5be8-033b-5bcd-59699a226002@xs4all.nl> <756729ed-18d6-519c-ba61-98afeecaa0b7@gpxsee.org> <2e7209cf-29c4-0245-fefe-deece350bd2c@xs4all.nl> From: =?UTF-8?Q?Martin_T=c5=afma?= In-Reply-To: <2e7209cf-29c4-0245-fefe-deece350bd2c@xs4all.nl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13. 06. 23 17:04, Hans Verkuil wrote: > Hi Martin, > > On 13/06/2023 16:46, Martin Tůma wrote: >> On 13. 06. 23 14:18, Hans Verkuil wrote: >>> Hi Martin, >>> >>> On 12/06/2023 13:34, Martin Tůma wrote: >>>> On 12. 06. 23 10:51, Hans Verkuil wrote: >>>>> On 08/06/2023 17:30, Martin Tůma wrote: >>>>>> On 08. 06. 23 12:23, Hans Verkuil wrote: >>>>>> >>>>>>> Can you make a list of which sysfs properties correspond to existing V4L2 >>>>>>> format or timing fields and which are 'new'? >>>>>>> >>>>>> >>>>>> On the left all the current mgb4 sysfs properties (see the admin-guide doc from the patch for description), on the right v4l2 structures where they could be mapped (may not be true for all of >>>>>> them in >>>>>> the patch, I will check it and update the code in v7) >>>>>> >>>>>> >>>>>> --- PCIE CARD --- >>>>>> >>>>>> module_type        - >>>>>> module_version        - >>>>>> fw_type            - >>>>>> fw_version        - >>>>>> serial_number        - >>>>>> temperature        hwmon >>>>>> >>>>>> --- INPUTS --- >>>>>> >>>>>> input_id        - >>>>>> oldi_lane_width        - >>>>>> color_mapping        - >>>>>> link_status        v4l2_input.status (V4L2_IN_ST_NO_SYNC) >>>>>> stream_status        v4l2_input.status (V4L2_IN_ST_NO_SIGNAL) >>>>>> video_width        v4l2_bt_timings.width >>>>>> video_height        v4l2_bt_timings.height >>>>>> vsync_status        v4l2_bt_timings.polarities >>>>>> hsync_status        v4l2_bt_timings.polarities >>>>>> vsync_gap_length    - >>>>>> hsync_gap_length    - >>>>>> pclk_frequency        v4l2_bt_timings.pixelclock >>>>>> hsync_width        v4l2_bt_timings.hsync >>>>>> vsync_width        v4l2_bt_timings.vsync >>>>>> hback_porch        v4l2_bt_timings.hbackporch >>>>>> hfront_porch        v4l2_bt_timings.hfrontporch >>>>>> vback_porch        v4l2_bt_timings.vbackporch >>>>>> vfront_porch        v4l2_bt_timings.vfrontporch >>>>>> frequency_range        - >>>>>> alignment        v4l2_pix_format.bytesperline >>>>>> fpdl3_input_width    - >>>>>> gmsl_mode        - >>>>>> gmsl_stream_id        - >>>>>> gmsl_fec        - >>>>>> >>>>>> --- OUTPUTS --- >>>>>> >>>>>> output_id        - >>>>>> video_source        - >>>>>> display_width        v4l2_bt_timings.width >>>>>> display_height        v4l2_bt_timings.height >>>>>> frame_rate        v4l2_frmivalenum >>>>> >>>>> The frame rate is a property of the width/height+blanking and the >>>>> pixel clock frequency. IMHO it does not make sense to have this as >>>>> a writable property. Read-only is OK. >>>>> >>>>>> hsync_polarity        v4l2_bt_timings.polarities >>>>>> vsync_polarity        v4l2_bt_timings.polarities >>>>>> de_polarity        - >>>>>> pclk_frequency        v4l2_bt_timings.pixelclock >>>>>> hsync_width        v4l2_bt_timings.hsync >>>>>> vsync_width        v4l2_bt_timings.vsync >>>>>> vsync_width        v4l2_bt_timings.vsync >>>>>> hback_porch        v4l2_bt_timings.hbackporch >>>>>> hfront_porch        v4l2_bt_timings.hfrontporch >>>>>> vback_porch        v4l2_bt_timings.vbackporch >>>>>> vfront_porch        v4l2_bt_timings.vfrontporch >>>>>> alignment        v4l2_pix_format.bytesperline >>>>>> fpdl3_output_width    - >>>>>> >>>>>> >>>>>> M. >>>>> >>>>> The property I am most concerned with is alignment (both for input and output). >>>>> But it is not clear to me what the use-case is. >>>>> >>>> >>>> Hi, >>>> The use-case is to provide the alignment required by some video processing chips. We have a product based on NVIDIA Jetson TX2 that uses the mgb4 cards and the HW video encoding needs a specific >>>> alignment to work. >>> >>> OK. I would suggest that for this property it has a default value of 0 (i.e. a 1 byte alignment), >>> and in that case VIDIOC_S_FMT allows userspace to set bytesperline to whatever they want. I.e., >>> this is the normal behavior for DMA engines that can deal with custom padding at the end of each >>> line. >>> >>> If it is > 0, then bytesperline is fixed, based on this value. >>> >>> That way both methods are supported fairly cleanly. >>> >>> BTW, what is missing in the property documentation for writable properties is what the default >>> value is. That must be documented as well. >>> >> >> The default value is 1 (no padding, 1 byte alignment), I will add it to the documentation. >> >> I would really urge to stick with the "set all the properties at one place in sysfs, report them in v4l2" mechanism. Like with most of the properties, there are some special cases and HW related >> dependencies across inputs/outputs (the output alignment has to comply with input alignment - see the documentation rst for details) and duplicating this logic together with some additional logic >> handling changes from another source - VIDIOC_S_FMT - will make the driver much more complicated and "messy" for no benefit for the user (he will be even more confused). > > When mainlining drivers it is important to support the standard APIs as much as possible, > otherwise it will become a big mess if every driver does something different. So as > maintainer it is my job to ensure that the standard APIs are used. > > Looking at the properties that were introduced, most are related to timings, except > for alignment. That is really something for VIDIOC_S_FMT. And should be perfectly > fine to support as long as alignment is set to 1. If it is > 1, then bytesperline can > be set by the driver and userspace can't change it. It adds only very little complexity, > but it ensures that the default behavior is consistent with the V4L2 API. > > I'm not very keen on all the properties at all, but given the specific nature of > this board I can understand it. They are to some extent similar to device tree > snippets to configure the device. But 'alignment' is not really part of that, > but I'm OK with it as long as the standard method is also supported. And in fact, > the property documentation should refer to the standard method as well. > Ok, I see your point. I will completely drop the alignment from sysfs and make it configurable only using VIDIOC_S_FMT. This "property" is/will be changed by special SW that uses the v4l2 API anyway. So it is not the case of all the required video stream properties where it is crucial for us that they can all be configured on a single place (using the same basic UDEV rules) and that generic SW like VLC or ffplay can be used to work with the video devices. M. > Regards, > > Hans