From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Pawel Osciak <p.osciak@samsung.com>
Cc: "'Aguirre, Sergio'" <saaguirre@ti.com>,
linux-media@vger.kernel.org, kyungmin.park@samsung.com
Subject: Re: [videobuf] Query: Condition bytesize limit in videobuf_reqbufs -> buf_setup() call?
Date: Thu, 06 May 2010 10:10:25 -0300 [thread overview]
Message-ID: <4BE2BFC1.1000701@redhat.com> (raw)
In-Reply-To: <000901caeceb$9ff6c5e0$dfe451a0$%osciak@samsung.com>
Pawel Osciak wrote:
> Hi,
>
>> Aguirre, Sergio wrote:
>> Basically, when calling VIDIOC_REQBUFS with a certain buffer
>> Count, we had a software limit for total size, calculated depending on:
>>
>> Total bytesize = bytesperline x height x count
>>
>> So, we had an arbitrary limit to, say 32 MB, which was generic.
>>
>> Now, we want to condition it ONLY when MMAP buffers will be used.
>> Meaning, we don't want to keep that policy when the kernel is not
>> allocating the space
>>
>> But the thing is that, according to videobuf documentation, buf_setup is
>> the one who should put a RAM usage limit. BUT the memory type passed to
>> reqbufs is not propagated to buf_setup, therefore forcing me to go to a
>> non-standard memory limitation in my reqbufs callback function, instead
>> of doing it properly inside buf_setup.
>
> buf_setup is called during REQBUFS and is indeed the place to limit the
> size and actually allocate the buffers as well, or at least try to do so,
> as V4L2 API requires. This is not currently the case with videobuf, but
> right now we are working to change it.
I can't see the problem you're mentioning. Drivers apply (or should apply)
the maximum size limit at buffer setup. For example bttv driver seems to do
the right thing:
static unsigned int gbuffers = 8;
static unsigned int gbufsize = 0x208000;
...
MODULE_PARM_DESC(gbuffers,"number of capture buffers. range 2-32, default 8");
MODULE_PARM_DESC(gbufsize,"size of the capture buffers, default is 0x208000");
...
static int
buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
{
struct bttv_fh *fh = q->priv_data;
*size = fh->fmt->depth*fh->width*fh->height >> 3;
if (0 == *count)
*count = gbuffers;
if (*size * *count > gbuffers * gbufsize)
*count = (gbuffers * gbufsize) / *size;
return 0;
}
> buf_prepare() is called on QBUF
> and it is definitely too late to do things like that then. It is the
> REQBUFS that should be failing if the requested number of buffers is too
> high.
Yes, it is too late. Restrictions like that should be done at REQBUFS.
--
Cheers,
Mauro
next prev parent reply other threads:[~2010-05-06 13:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 20:53 [videobuf] Query: Condition bytesize limit in videobuf_reqbufs -> buf_setup() call? Aguirre, Sergio
2010-05-05 23:24 ` Mauro Carvalho Chehab
2010-05-05 23:29 ` Aguirre, Sergio
2010-05-05 23:52 ` Mauro Carvalho Chehab
2010-05-06 8:09 ` Laurent Pinchart
2010-05-06 12:38 ` Mauro Carvalho Chehab
2010-05-06 13:03 ` Laurent Pinchart
2010-05-06 13:23 ` Mauro Carvalho Chehab
2010-05-06 14:52 ` Laurent Pinchart
2010-05-06 7:13 ` Pawel Osciak
2010-05-06 13:10 ` Mauro Carvalho Chehab [this message]
2010-05-06 13:29 ` Pawel Osciak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BE2BFC1.1000701@redhat.com \
--to=mchehab@redhat.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-media@vger.kernel.org \
--cc=p.osciak@samsung.com \
--cc=saaguirre@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.