Message ID | 20190412155915.16849-1-stanimir.varbanov@linaro.org (mailing list archive) |
---|---|
State | Changes Requested, archived |
Delegated to: | Hans Verkuil |
Headers |
Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from <linux-media-owner@vger.kernel.org>) id 1hEyaV-00072c-VN; Fri, 12 Apr 2019 15:59:36 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726994AbfDLP7c (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Fri, 12 Apr 2019 11:59:32 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36545 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbfDLP7b (ORCPT <rfc822;linux-media@vger.kernel.org>); Fri, 12 Apr 2019 11:59:31 -0400 Received: by mail-wr1-f67.google.com with SMTP id y13so12647226wrd.3 for <linux-media@vger.kernel.org>; Fri, 12 Apr 2019 08:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=90rwpXEXFGoNt9j8MqywsjEPW+NzjmMm6jkw8wsUGVA=; b=s+ifSMihs8ddL09X415RQy/hlbE8x22tzAPwKBQ71Nc7WSkPJXiXi4aNMcdlRItpQB 6HQYeA702yfHyVRTvUiIV0tN+XQHPRlo58QIMtt6ENDVgc63ViF9YfRj1w7+5j/P2qxe 2howVQi3eI14kMTWwM6/iqB6wIUD9ulWOdaLIt3oJprpM65dzpwccSfTplmdXibJbHud Wuoy123UmX7qB6pgOolOl11GwKta3U3Y8VGFowm6UeniM8Ove+DeErJ6IIhej1O9Fqek gR9zL5brBEfgc41syQd3vZGZ/kKatGYFh78HfFYV/hoqsFM1EUr9TAYsSYWQVNZEzbtC FoiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=90rwpXEXFGoNt9j8MqywsjEPW+NzjmMm6jkw8wsUGVA=; b=lvWDjzvJMJ53Cz97YzmPMiWjRC8XgzhAQzDb+6YCsGkAWv1PSACLV4L65hpc39fdb6 abxnsf7dckNcBqmYdZZCm33X+4jNIjUKXCOFquVh54ryCcjb7MEoycpiuEsGQb1cY7vy DJpCowns7Ch7nTGSfrZMEiKgCU5zSnKdXi1eElOLJVBCyn7aU/H27E2BkmLzPRWkEFcZ 3lAKYsHoAQ+wiyX05lKi3B+8WMyMGcZLPiJ7khS2ri1nbHTyayxxcsfe5YCBjaB1Lrxc RqmP+6HHA2dxZAaqGQVDzGU2L4cjp/bdCaEErm1oG+3Odmx7MMJiTqtYfn05slgaNE0L vqSw== X-Gm-Message-State: APjAAAXHJEcRxXZWVz8X8K1T8AkeOk+KWMVAFfr3iafRoAHrIVE8/hSG SX+RRld9xry4t6BP1v172x8z8SrFif4= X-Google-Smtp-Source: APXvYqzQNgPoaW/WaGC5ih7Q2ZmwYpBFGHEngHKVMvZ0hwor0vP+g5fOqu9HiWVIDFJsJJcarpuKow== X-Received: by 2002:adf:db0c:: with SMTP id s12mr36574749wri.184.1555084769753; Fri, 12 Apr 2019 08:59:29 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id b134sm15745440wmd.26.2019.04.12.08.59.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 08:59:29 -0700 (PDT) From: Stanimir Varbanov <stanimir.varbanov@linaro.org> To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab <mchehab@kernel.org>, Hans Verkuil <hverkuil@xs4all.nl>, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov <stanimir.varbanov@linaro.org> Subject: [PATCH v2] media/doc: Allow sizeimage to be set by v4l clients Date: Fri, 12 Apr 2019 18:59:15 +0300 Message-Id: <20190412155915.16849-1-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org |
Commit Message
Stanimir Varbanov
April 12, 2019, 3:59 p.m. UTC
This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage
field description to allow v4l clients to set bigger image size
in case of variable length compressed data.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
---
Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 13 ++++++++++++-
Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 11 ++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
Comments
Em Fri, 12 Apr 2019 18:59:15 +0300 Stanimir Varbanov <stanimir.varbanov@linaro.org> escreveu: > This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage > field description to allow v4l clients to set bigger image size > in case of variable length compressed data. > > Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> > --- > Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 13 ++++++++++++- > Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 11 ++++++++++- > 2 files changed, 22 insertions(+), 2 deletions(-) > > diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > index 5688c816e334..005428a8121e 100644 > --- a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > @@ -31,7 +31,18 @@ describing all planes of that format. > > * - __u32 > - ``sizeimage`` > - - Maximum size in bytes required for image data in this plane. > + - Maximum size in bytes required for image data in this plane, > + set by the driver. When the image consists of variable length > + compressed data this is the number of bytes required by the > + codec to support the worst-case compression scenario. > + > + For uncompressed images the driver will set the value. For > + variable length compressed data clients are allowed to set > + the sizeimage field, but the driver may ignore it and set the > + value itself, or it may modify the provided value based on > + alignment requirements or minimum/maximum size requirements. > + If the client wants to leave this to the driver, then it should > + set sizeimage to 0. > * - __u32 > - ``bytesperline`` > - Distance in bytes between the leftmost pixels in two adjacent > diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > index 71eebfc6d853..0f7771151db9 100644 > --- a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > @@ -89,7 +89,16 @@ Single-planar format structure > - Size in bytes of the buffer to hold a complete image, set by the > driver. Usually this is ``bytesperline`` times ``height``. When > the image consists of variable length compressed data this is the > - maximum number of bytes required to hold an image. > + number of bytes required by the codec to support the worst-case > + compression scenario. > + > + For uncompressed images the driver will set the value. For > + variable length compressed data clients are allowed to set > + the sizeimage field, but the driver may ignore it and set the > + value itself, or it may modify the provided value based on > + alignment requirements or minimum/maximum size requirements. > + If the client wants to leave this to the driver, then it should > + set sizeimage to 0. It is very confusing to understand what you meant by the above paragraph, as you inverted the sentence order and forgot a comma. I would, instead, write the phrases using the direct order, and break into two paragraphs, e. g., changing the above to: "The driver will set the value for uncompressed images. Clients are allowed to set the sizeimage field for variable length compressed data, but the driver may ignore it and set the value itself, or it may modify the provided value based on alignment requirements or minimum/maximum size requirements. If the client wants to leave this to the driver, then it should set sizeimage to 0." That makes it a lot easier to read, hopefully preventing mistakes from app and driver developers when reading about sizeimage. Yet, I'm not too comfortable on letting this too generic. I mean, how an app writer would know what formats are "variable length compressed data", specially since libv4l may actually change that. Thanks, Mauro
On 5/2/19 2:55 PM, Mauro Carvalho Chehab wrote: > Em Fri, 12 Apr 2019 18:59:15 +0300 > Stanimir Varbanov <stanimir.varbanov@linaro.org> escreveu: > >> This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage >> field description to allow v4l clients to set bigger image size >> in case of variable length compressed data. >> >> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> >> --- >> Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 13 ++++++++++++- >> Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 11 ++++++++++- >> 2 files changed, 22 insertions(+), 2 deletions(-) >> >> diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >> index 5688c816e334..005428a8121e 100644 >> --- a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >> +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >> @@ -31,7 +31,18 @@ describing all planes of that format. >> >> * - __u32 >> - ``sizeimage`` >> - - Maximum size in bytes required for image data in this plane. >> + - Maximum size in bytes required for image data in this plane, >> + set by the driver. When the image consists of variable length >> + compressed data this is the number of bytes required by the >> + codec to support the worst-case compression scenario. >> + >> + For uncompressed images the driver will set the value. For >> + variable length compressed data clients are allowed to set >> + the sizeimage field, but the driver may ignore it and set the >> + value itself, or it may modify the provided value based on >> + alignment requirements or minimum/maximum size requirements. >> + If the client wants to leave this to the driver, then it should >> + set sizeimage to 0. >> * - __u32 >> - ``bytesperline`` >> - Distance in bytes between the leftmost pixels in two adjacent >> diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >> index 71eebfc6d853..0f7771151db9 100644 >> --- a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >> +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >> @@ -89,7 +89,16 @@ Single-planar format structure >> - Size in bytes of the buffer to hold a complete image, set by the >> driver. Usually this is ``bytesperline`` times ``height``. When >> the image consists of variable length compressed data this is the >> - maximum number of bytes required to hold an image. >> + number of bytes required by the codec to support the worst-case >> + compression scenario. >> + >> + For uncompressed images the driver will set the value. For >> + variable length compressed data clients are allowed to set >> + the sizeimage field, but the driver may ignore it and set the >> + value itself, or it may modify the provided value based on >> + alignment requirements or minimum/maximum size requirements. >> + If the client wants to leave this to the driver, then it should >> + set sizeimage to 0. > > It is very confusing to understand what you meant by the above paragraph, > as you inverted the sentence order and forgot a comma. > > I would, instead, write the phrases using the direct order, and break > into two paragraphs, e. g., changing the above to: > > "The driver will set the value for uncompressed images. > > Clients are allowed to set the sizeimage field for variable length > compressed data, but the driver may ignore it and set the > value itself, or it may modify the provided value based on > alignment requirements or minimum/maximum size requirements. > If the client wants to leave this to the driver, then it should > set sizeimage to 0." > > That makes it a lot easier to read, hopefully preventing mistakes from > app and driver developers when reading about sizeimage. > > Yet, I'm not too comfortable on letting this too generic. I mean, > how an app writer would know what formats are "variable length > compressed data", specially since libv4l may actually change that. It's actually quite clearly defined: compressed formats set the V4L2_FMT_FLAG_COMPRESSED flag in VIDIOC_ENUMFMT. Also bytesperline will be 0 for compressed formats. Regards, Hans > > Thanks, > Mauro >
Em Thu, 2 May 2019 15:16:54 +0200 Hans Verkuil <hverkuil@xs4all.nl> escreveu: > On 5/2/19 2:55 PM, Mauro Carvalho Chehab wrote: > > Em Fri, 12 Apr 2019 18:59:15 +0300 > > Stanimir Varbanov <stanimir.varbanov@linaro.org> escreveu: > > > >> This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage > >> field description to allow v4l clients to set bigger image size > >> in case of variable length compressed data. > >> > >> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> > >> --- > >> Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 13 ++++++++++++- > >> Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 11 ++++++++++- > >> 2 files changed, 22 insertions(+), 2 deletions(-) > >> > >> diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > >> index 5688c816e334..005428a8121e 100644 > >> --- a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > >> +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > >> @@ -31,7 +31,18 @@ describing all planes of that format. > >> > >> * - __u32 > >> - ``sizeimage`` > >> - - Maximum size in bytes required for image data in this plane. > >> + - Maximum size in bytes required for image data in this plane, > >> + set by the driver. When the image consists of variable length > >> + compressed data this is the number of bytes required by the > >> + codec to support the worst-case compression scenario. > >> + > >> + For uncompressed images the driver will set the value. For > >> + variable length compressed data clients are allowed to set > >> + the sizeimage field, but the driver may ignore it and set the > >> + value itself, or it may modify the provided value based on > >> + alignment requirements or minimum/maximum size requirements. > >> + If the client wants to leave this to the driver, then it should > >> + set sizeimage to 0. > >> * - __u32 > >> - ``bytesperline`` > >> - Distance in bytes between the leftmost pixels in two adjacent > >> diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > >> index 71eebfc6d853..0f7771151db9 100644 > >> --- a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > >> +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > >> @@ -89,7 +89,16 @@ Single-planar format structure > >> - Size in bytes of the buffer to hold a complete image, set by the > >> driver. Usually this is ``bytesperline`` times ``height``. When > >> the image consists of variable length compressed data this is the > >> - maximum number of bytes required to hold an image. > >> + number of bytes required by the codec to support the worst-case > >> + compression scenario. > >> + > >> + For uncompressed images the driver will set the value. For > >> + variable length compressed data clients are allowed to set > >> + the sizeimage field, but the driver may ignore it and set the > >> + value itself, or it may modify the provided value based on > >> + alignment requirements or minimum/maximum size requirements. > >> + If the client wants to leave this to the driver, then it should > >> + set sizeimage to 0. > > > > It is very confusing to understand what you meant by the above paragraph, > > as you inverted the sentence order and forgot a comma. > > > > I would, instead, write the phrases using the direct order, and break > > into two paragraphs, e. g., changing the above to: > > > > "The driver will set the value for uncompressed images. > > > > Clients are allowed to set the sizeimage field for variable length > > compressed data, but the driver may ignore it and set the > > value itself, or it may modify the provided value based on > > alignment requirements or minimum/maximum size requirements. > > If the client wants to leave this to the driver, then it should > > set sizeimage to 0." > > > > That makes it a lot easier to read, hopefully preventing mistakes from > > app and driver developers when reading about sizeimage. > > > > Yet, I'm not too comfortable on letting this too generic. I mean, > > how an app writer would know what formats are "variable length > > compressed data", specially since libv4l may actually change that. > > It's actually quite clearly defined: compressed formats set the > V4L2_FMT_FLAG_COMPRESSED flag in VIDIOC_ENUMFMT. Ok, so let's be explicit here, e. g. something like: "Clients are allowed to set the sizeimage field for variable length compressed data flagged with V4L2_FMT_FLAG_COMPRESSED at VIDIOC_ENUMFMT, but the driver may ignore it and set the value itself, or it may modify the provided value based on alignment requirements or minimum/maximum size requirements. If the client wants to leave this to the driver, then it should set sizeimage to 0." That makes clear for app developers when they can use this new feature. That still leads us to what happens at libv4l with sizeimage for a compressed format that got uncompressed by the library, in order to ensure that a change like this won't cause breakages at existing userspace apps. > > Also bytesperline will be 0 for compressed formats. > > Regards, > > Hans > > > > > Thanks, > > Mauro > > > Thanks, Mauro
Hi Mauro, Thanks for comments! On 5/2/19 4:29 PM, Mauro Carvalho Chehab wrote: > Em Thu, 2 May 2019 15:16:54 +0200 > Hans Verkuil <hverkuil@xs4all.nl> escreveu: > >> On 5/2/19 2:55 PM, Mauro Carvalho Chehab wrote: >>> Em Fri, 12 Apr 2019 18:59:15 +0300 >>> Stanimir Varbanov <stanimir.varbanov@linaro.org> escreveu: >>> >>>> This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage >>>> field description to allow v4l clients to set bigger image size >>>> in case of variable length compressed data. >>>> >>>> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> >>>> --- >>>> Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 13 ++++++++++++- >>>> Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 11 ++++++++++- >>>> 2 files changed, 22 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >>>> index 5688c816e334..005428a8121e 100644 >>>> --- a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >>>> +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >>>> @@ -31,7 +31,18 @@ describing all planes of that format. >>>> >>>> * - __u32 >>>> - ``sizeimage`` >>>> - - Maximum size in bytes required for image data in this plane. >>>> + - Maximum size in bytes required for image data in this plane, >>>> + set by the driver. When the image consists of variable length >>>> + compressed data this is the number of bytes required by the >>>> + codec to support the worst-case compression scenario. >>>> + >>>> + For uncompressed images the driver will set the value. For >>>> + variable length compressed data clients are allowed to set >>>> + the sizeimage field, but the driver may ignore it and set the >>>> + value itself, or it may modify the provided value based on >>>> + alignment requirements or minimum/maximum size requirements. >>>> + If the client wants to leave this to the driver, then it should >>>> + set sizeimage to 0. >>>> * - __u32 >>>> - ``bytesperline`` >>>> - Distance in bytes between the leftmost pixels in two adjacent >>>> diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >>>> index 71eebfc6d853..0f7771151db9 100644 >>>> --- a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >>>> +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >>>> @@ -89,7 +89,16 @@ Single-planar format structure >>>> - Size in bytes of the buffer to hold a complete image, set by the >>>> driver. Usually this is ``bytesperline`` times ``height``. When >>>> the image consists of variable length compressed data this is the >>>> - maximum number of bytes required to hold an image. >>>> + number of bytes required by the codec to support the worst-case >>>> + compression scenario. >>>> + >>>> + For uncompressed images the driver will set the value. For >>>> + variable length compressed data clients are allowed to set >>>> + the sizeimage field, but the driver may ignore it and set the >>>> + value itself, or it may modify the provided value based on >>>> + alignment requirements or minimum/maximum size requirements. >>>> + If the client wants to leave this to the driver, then it should >>>> + set sizeimage to 0. >>> >>> It is very confusing to understand what you meant by the above paragraph, >>> as you inverted the sentence order and forgot a comma. >>> >>> I would, instead, write the phrases using the direct order, and break >>> into two paragraphs, e. g., changing the above to: >>> >>> "The driver will set the value for uncompressed images. >>> >>> Clients are allowed to set the sizeimage field for variable length >>> compressed data, but the driver may ignore it and set the >>> value itself, or it may modify the provided value based on >>> alignment requirements or minimum/maximum size requirements. >>> If the client wants to leave this to the driver, then it should >>> set sizeimage to 0." >>> >>> That makes it a lot easier to read, hopefully preventing mistakes from >>> app and driver developers when reading about sizeimage. >>> >>> Yet, I'm not too comfortable on letting this too generic. I mean, >>> how an app writer would know what formats are "variable length >>> compressed data", specially since libv4l may actually change that. >> >> It's actually quite clearly defined: compressed formats set the >> V4L2_FMT_FLAG_COMPRESSED flag in VIDIOC_ENUMFMT. > > Ok, so let's be explicit here, e. g. something like: > > "Clients are allowed to set the sizeimage field for variable length > compressed data flagged with V4L2_FMT_FLAG_COMPRESSED at > VIDIOC_ENUMFMT, but the driver may ignore it and set the > value itself, or it may modify the provided value based on > alignment requirements or minimum/maximum size requirements. > If the client wants to leave this to the driver, then it should > set sizeimage to 0." > > That makes clear for app developers when they can use this new > feature. OK, I will resend with that description. > > That still leads us to what happens at libv4l with sizeimage > for a compressed format that got uncompressed by the library, in > order to ensure that a change like this won't cause breakages at > existing userspace apps. libv4l can decompress formats like MJPEG, right? I mean it isn't to decompress MPEG/H264 for example.
Hi Stanimir, On 4/12/19 5:59 PM, Stanimir Varbanov wrote: > This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage > field description to allow v4l clients to set bigger image size > in case of variable length compressed data. I've been reconsidering this change. The sizeimage value in the format is the minimum size a buffer should have in order to store the data of an image of the width and height as described in the format. But there is nothing that prevents userspace from calling VIDIOC_CREATEBUFS instead of VIDIOC_REQBUFS to allocate larger buffers. So do we really need this change? The more I think about this, the more uncomfortable I become with this change. Regards, Hans > > Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> > --- > Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 13 ++++++++++++- > Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 11 ++++++++++- > 2 files changed, 22 insertions(+), 2 deletions(-) > > diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > index 5688c816e334..005428a8121e 100644 > --- a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > @@ -31,7 +31,18 @@ describing all planes of that format. > > * - __u32 > - ``sizeimage`` > - - Maximum size in bytes required for image data in this plane. > + - Maximum size in bytes required for image data in this plane, > + set by the driver. When the image consists of variable length > + compressed data this is the number of bytes required by the > + codec to support the worst-case compression scenario. > + > + For uncompressed images the driver will set the value. For > + variable length compressed data clients are allowed to set > + the sizeimage field, but the driver may ignore it and set the > + value itself, or it may modify the provided value based on > + alignment requirements or minimum/maximum size requirements. > + If the client wants to leave this to the driver, then it should > + set sizeimage to 0. > * - __u32 > - ``bytesperline`` > - Distance in bytes between the leftmost pixels in two adjacent > diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > index 71eebfc6d853..0f7771151db9 100644 > --- a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > @@ -89,7 +89,16 @@ Single-planar format structure > - Size in bytes of the buffer to hold a complete image, set by the > driver. Usually this is ``bytesperline`` times ``height``. When > the image consists of variable length compressed data this is the > - maximum number of bytes required to hold an image. > + number of bytes required by the codec to support the worst-case > + compression scenario. > + > + For uncompressed images the driver will set the value. For > + variable length compressed data clients are allowed to set > + the sizeimage field, but the driver may ignore it and set the > + value itself, or it may modify the provided value based on > + alignment requirements or minimum/maximum size requirements. > + If the client wants to leave this to the driver, then it should > + set sizeimage to 0. > * - __u32 > - ``colorspace`` > - Image colorspace, from enum :c:type:`v4l2_colorspace`. >
Le mardi 14 mai 2019 à 10:54 +0200, Hans Verkuil a écrit : > Hi Stanimir, > > On 4/12/19 5:59 PM, Stanimir Varbanov wrote: > > This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage > > field description to allow v4l clients to set bigger image size > > in case of variable length compressed data. > > I've been reconsidering this change. The sizeimage value in the format > is the minimum size a buffer should have in order to store the data of > an image of the width and height as described in the format. Should this read as the minimum size for the specific (returned by driver) width/height/bytesperline ? > > But there is nothing that prevents userspace from calling VIDIOC_CREATEBUFS > instead of VIDIOC_REQBUFS to allocate larger buffers. > > So do we really need this change? > > The more I think about this, the more uncomfortable I become with this change. > > Regards, > > Hans > > > Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> > > --- > > Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 13 ++++++++++++- > > Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 11 ++++++++++- > > 2 files changed, 22 insertions(+), 2 deletions(-) > > > > diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > > index 5688c816e334..005428a8121e 100644 > > --- a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > > +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst > > @@ -31,7 +31,18 @@ describing all planes of that format. > > > > * - __u32 > > - ``sizeimage`` > > - - Maximum size in bytes required for image data in this plane. > > + - Maximum size in bytes required for image data in this plane, > > + set by the driver. When the image consists of variable length > > + compressed data this is the number of bytes required by the > > + codec to support the worst-case compression scenario. > > + > > + For uncompressed images the driver will set the value. For > > + variable length compressed data clients are allowed to set > > + the sizeimage field, but the driver may ignore it and set the > > + value itself, or it may modify the provided value based on > > + alignment requirements or minimum/maximum size requirements. > > + If the client wants to leave this to the driver, then it should > > + set sizeimage to 0. > > * - __u32 > > - ``bytesperline`` > > - Distance in bytes between the leftmost pixels in two adjacent > > diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > > index 71eebfc6d853..0f7771151db9 100644 > > --- a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > > +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst > > @@ -89,7 +89,16 @@ Single-planar format structure > > - Size in bytes of the buffer to hold a complete image, set by the > > driver. Usually this is ``bytesperline`` times ``height``. When > > the image consists of variable length compressed data this is the > > - maximum number of bytes required to hold an image. > > + number of bytes required by the codec to support the worst-case > > + compression scenario. > > + > > + For uncompressed images the driver will set the value. For > > + variable length compressed data clients are allowed to set > > + the sizeimage field, but the driver may ignore it and set the > > + value itself, or it may modify the provided value based on > > + alignment requirements or minimum/maximum size requirements. > > + If the client wants to leave this to the driver, then it should > > + set sizeimage to 0. > > * - __u32 > > - ``colorspace`` > > - Image colorspace, from enum :c:type:`v4l2_colorspace`. > >
On 5/14/19 2:19 PM, Nicolas Dufresne wrote: > Le mardi 14 mai 2019 à 10:54 +0200, Hans Verkuil a écrit : >> Hi Stanimir, >> >> On 4/12/19 5:59 PM, Stanimir Varbanov wrote: >>> This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage >>> field description to allow v4l clients to set bigger image size >>> in case of variable length compressed data. >> >> I've been reconsidering this change. The sizeimage value in the format >> is the minimum size a buffer should have in order to store the data of >> an image of the width and height as described in the format. > > Should this read as the minimum size for the specific (returned by > driver) width/height/bytesperline ? Yes. Although for compressed formats the bytesperline value plays no role of course. Regards, Hans > >> >> But there is nothing that prevents userspace from calling VIDIOC_CREATEBUFS >> instead of VIDIOC_REQBUFS to allocate larger buffers. >> >> So do we really need this change? >> >> The more I think about this, the more uncomfortable I become with this change. >> >> Regards, >> >> Hans >> >>> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> >>> --- >>> Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 13 ++++++++++++- >>> Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 11 ++++++++++- >>> 2 files changed, 22 insertions(+), 2 deletions(-) >>> >>> diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >>> index 5688c816e334..005428a8121e 100644 >>> --- a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >>> +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst >>> @@ -31,7 +31,18 @@ describing all planes of that format. >>> >>> * - __u32 >>> - ``sizeimage`` >>> - - Maximum size in bytes required for image data in this plane. >>> + - Maximum size in bytes required for image data in this plane, >>> + set by the driver. When the image consists of variable length >>> + compressed data this is the number of bytes required by the >>> + codec to support the worst-case compression scenario. >>> + >>> + For uncompressed images the driver will set the value. For >>> + variable length compressed data clients are allowed to set >>> + the sizeimage field, but the driver may ignore it and set the >>> + value itself, or it may modify the provided value based on >>> + alignment requirements or minimum/maximum size requirements. >>> + If the client wants to leave this to the driver, then it should >>> + set sizeimage to 0. >>> * - __u32 >>> - ``bytesperline`` >>> - Distance in bytes between the leftmost pixels in two adjacent >>> diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >>> index 71eebfc6d853..0f7771151db9 100644 >>> --- a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >>> +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst >>> @@ -89,7 +89,16 @@ Single-planar format structure >>> - Size in bytes of the buffer to hold a complete image, set by the >>> driver. Usually this is ``bytesperline`` times ``height``. When >>> the image consists of variable length compressed data this is the >>> - maximum number of bytes required to hold an image. >>> + number of bytes required by the codec to support the worst-case >>> + compression scenario. >>> + >>> + For uncompressed images the driver will set the value. For >>> + variable length compressed data clients are allowed to set >>> + the sizeimage field, but the driver may ignore it and set the >>> + value itself, or it may modify the provided value based on >>> + alignment requirements or minimum/maximum size requirements. >>> + If the client wants to leave this to the driver, then it should >>> + set sizeimage to 0. >>> * - __u32 >>> - ``colorspace`` >>> - Image colorspace, from enum :c:type:`v4l2_colorspace`. >>> >
Hi Hans, On 5/14/19 11:54 AM, Hans Verkuil wrote: > Hi Stanimir, > > On 4/12/19 5:59 PM, Stanimir Varbanov wrote: >> This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage >> field description to allow v4l clients to set bigger image size >> in case of variable length compressed data. > > I've been reconsidering this change. The sizeimage value in the format > is the minimum size a buffer should have in order to store the data of > an image of the width and height as described in the format. > > But there is nothing that prevents userspace from calling VIDIOC_CREATEBUFS > instead of VIDIOC_REQBUFS to allocate larger buffers. Sometimes CREATEBUFS cannot be implemented for a particular fw/hw. CC: Tomasz for his opinion. > > So do we really need this change? > > The more I think about this, the more uncomfortable I become with this change. > > Regards, > > Hans > <cut>
On Thu, May 16, 2019 at 5:09 PM Stanimir Varbanov <stanimir.varbanov@linaro.org> wrote: > > Hi Hans, > > On 5/14/19 11:54 AM, Hans Verkuil wrote: > > Hi Stanimir, > > > > On 4/12/19 5:59 PM, Stanimir Varbanov wrote: > >> This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage > >> field description to allow v4l clients to set bigger image size > >> in case of variable length compressed data. > > > > I've been reconsidering this change. The sizeimage value in the format > > is the minimum size a buffer should have in order to store the data of > > an image of the width and height as described in the format. > > > > But there is nothing that prevents userspace from calling VIDIOC_CREATEBUFS > > instead of VIDIOC_REQBUFS to allocate larger buffers. > > Sometimes CREATEBUFS cannot be implemented for a particular fw/hw. > > CC: Tomasz for his opinion. > Thanks Stanimir. Actually, if called at the same point in time as REQBUFS, CREATE_BUFS doesn't really differ to much, except that it gives more flexibility for allocating the buffers and that shouldn't depend on any specific features of hardware or firmware. Actually, one could even allocate any buffers any time regardless of hardware/firmware support, but the ability to use such buffers would actually depend on such. Perhaps we should just let the drivers return -EBUSY from CREATE_BUFS if called at the wrong time? > > > > So do we really need this change? > > Yes, because this has worked like this all the time, but it was just not documented. Disallowing this would break quite a bit of existing userspace. Best regards, Tomasz > > The more I think about this, the more uncomfortable I become with this change. > > > > Regards, > > > > Hans > > > > <cut> > > -- > regards, > Stan
On 5/16/19 11:56 AM, Tomasz Figa wrote: > On Thu, May 16, 2019 at 5:09 PM Stanimir Varbanov > <stanimir.varbanov@linaro.org> wrote: >> >> Hi Hans, >> >> On 5/14/19 11:54 AM, Hans Verkuil wrote: >>> Hi Stanimir, >>> >>> On 4/12/19 5:59 PM, Stanimir Varbanov wrote: >>>> This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage >>>> field description to allow v4l clients to set bigger image size >>>> in case of variable length compressed data. >>> >>> I've been reconsidering this change. The sizeimage value in the format >>> is the minimum size a buffer should have in order to store the data of >>> an image of the width and height as described in the format. >>> >>> But there is nothing that prevents userspace from calling VIDIOC_CREATEBUFS >>> instead of VIDIOC_REQBUFS to allocate larger buffers. >> >> Sometimes CREATEBUFS cannot be implemented for a particular fw/hw. >> >> CC: Tomasz for his opinion. >> > > Thanks Stanimir. > > Actually, if called at the same point in time as REQBUFS, CREATE_BUFS > doesn't really differ to much, except that it gives more flexibility > for allocating the buffers and that shouldn't depend on any specific > features of hardware or firmware. > > Actually, one could even allocate any buffers any time regardless of > hardware/firmware support, but the ability to use such buffers would > actually depend on such. > > Perhaps we should just let the drivers return -EBUSY from CREATE_BUFS > if called at the wrong time? > >>> >>> So do we really need this change? >>> > > Yes, because this has worked like this all the time, but it was just > not documented. Disallowing this would break quite a bit of existing > userspace. Which drivers allow this today? I think that would be useful information for the commit log of a v4 of this patch. Regards, Hans > > Best regards, > Tomasz > >>> The more I think about this, the more uncomfortable I become with this change. >>> >>> Regards, >>> >>> Hans >>> >> >> <cut> >> >> -- >> regards, >> Stan
Hi Hans, On 5/16/19 1:40 PM, Hans Verkuil wrote: > On 5/16/19 11:56 AM, Tomasz Figa wrote: >> On Thu, May 16, 2019 at 5:09 PM Stanimir Varbanov >> <stanimir.varbanov@linaro.org> wrote: >>> >>> Hi Hans, >>> >>> On 5/14/19 11:54 AM, Hans Verkuil wrote: >>>> Hi Stanimir, >>>> >>>> On 4/12/19 5:59 PM, Stanimir Varbanov wrote: >>>>> This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage >>>>> field description to allow v4l clients to set bigger image size >>>>> in case of variable length compressed data. >>>> >>>> I've been reconsidering this change. The sizeimage value in the format >>>> is the minimum size a buffer should have in order to store the data of >>>> an image of the width and height as described in the format. >>>> >>>> But there is nothing that prevents userspace from calling VIDIOC_CREATEBUFS >>>> instead of VIDIOC_REQBUFS to allocate larger buffers. >>> >>> Sometimes CREATEBUFS cannot be implemented for a particular fw/hw. >>> >>> CC: Tomasz for his opinion. >>> >> >> Thanks Stanimir. >> >> Actually, if called at the same point in time as REQBUFS, CREATE_BUFS >> doesn't really differ to much, except that it gives more flexibility >> for allocating the buffers and that shouldn't depend on any specific >> features of hardware or firmware. >> >> Actually, one could even allocate any buffers any time regardless of >> hardware/firmware support, but the ability to use such buffers would >> actually depend on such. >> >> Perhaps we should just let the drivers return -EBUSY from CREATE_BUFS >> if called at the wrong time? >> >>>> >>>> So do we really need this change? >>>> >> >> Yes, because this has worked like this all the time, but it was just >> not documented. Disallowing this would break quite a bit of existing >> userspace. > > Which drivers allow this today? I think that would be useful information > for the commit log of a v4 of this patch. > I'd say s5p-mfc and mtk-vcodec at least.
diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst index 5688c816e334..005428a8121e 100644 --- a/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst @@ -31,7 +31,18 @@ describing all planes of that format. * - __u32 - ``sizeimage`` - - Maximum size in bytes required for image data in this plane. + - Maximum size in bytes required for image data in this plane, + set by the driver. When the image consists of variable length + compressed data this is the number of bytes required by the + codec to support the worst-case compression scenario. + + For uncompressed images the driver will set the value. For + variable length compressed data clients are allowed to set + the sizeimage field, but the driver may ignore it and set the + value itself, or it may modify the provided value based on + alignment requirements or minimum/maximum size requirements. + If the client wants to leave this to the driver, then it should + set sizeimage to 0. * - __u32 - ``bytesperline`` - Distance in bytes between the leftmost pixels in two adjacent diff --git a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst index 71eebfc6d853..0f7771151db9 100644 --- a/Documentation/media/uapi/v4l/pixfmt-v4l2.rst +++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst @@ -89,7 +89,16 @@ Single-planar format structure - Size in bytes of the buffer to hold a complete image, set by the driver. Usually this is ``bytesperline`` times ``height``. When the image consists of variable length compressed data this is the - maximum number of bytes required to hold an image. + number of bytes required by the codec to support the worst-case + compression scenario. + + For uncompressed images the driver will set the value. For + variable length compressed data clients are allowed to set + the sizeimage field, but the driver may ignore it and set the + value itself, or it may modify the provided value based on + alignment requirements or minimum/maximum size requirements. + If the client wants to leave this to the driver, then it should + set sizeimage to 0. * - __u32 - ``colorspace`` - Image colorspace, from enum :c:type:`v4l2_colorspace`.