linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>
Subject: RFC: Negotiating frame buffer size between sensor subdevs and bridge devices
Date: Thu, 28 Jul 2011 19:04:11 +0200	[thread overview]
Message-ID: <4E31968B.9080603@samsung.com> (raw)

Hello,

Trying to capture images in JPEG format with regular "image sensor -> 
mipi-csi receiver -> host interface" H/W configuration I've found there
is no standard way to communicate between the sensor subdev and the host
driver what is exactly a required maximum buffer size to capture a frame.

For the raw formats there is no issue as the buffer size can be easily
determined from the pixel format and resolution (or sizeimage set on
a video node). 
However compressed data formats are a bit more complicated, the required
memory buffer size depends on multiple factors, like compression ratio,
exact file header structure etc.

Often it is at the sensor driver where all information required to 
determine size of the allocated memory is present. Bridge/host devices
just do plain DMA without caring much what is transferred. I know of
hardware which, for some pixel formats, once data capture is started,
writes to memory whatever amount of data the sensor is transmitting,
without any means to interrupt on the host side. So it is critical
to assure the buffer allocation is done right, according to the sensor
requirements, to avoid buffer overrun.


Here is a link to somehow related discussion I could find:
[1] http://www.mail-archive.com/linux-media@vger.kernel.org/msg27138.html


In order to let the host drivers query or configure subdevs with required
frame buffer size one of the following changes could be done at V4L2 API:

1. Add a 'sizeimage' field in struct v4l2_mbus_framefmt and make subdev
 drivers optionally set/adjust it when setting or getting the format with
 set_fmt/get_fmt pad level ops (and s/g_mbus_fmt ?)
 There could be two situations:
 - effective required frame buffer size is specified by the sensor and the
   host driver relies on that value when allocating a buffer;
 - the host driver forces some arbitrary buffer size and the sensor performs
   any required action to limit transmitted amount of data to that amount
   of data;

Both cases could be covered similarly as it's done with VIDIOC_S_FMT. 

Introducing 'sizeimage' field is making the media bus format struct looking
more similar to struct v4l2_pix_format and not quite in line with media bus
format meaning, i.e. describing data on a physical bus, not in the memory.
The other option I can think of is to create separate subdev video ops.


2. Add new s/g_sizeimage subdev video operations 

The best would be to make this an optional callback, not sure if it makes sense
though. It has an advantage of not polluting the user space API. Although 
'sizeimage' in user space might be useful for some purposes I rather tried to
focus on "in-kernel" calls.
 

Comments? Better ideas?


Thanks,
-- 
Sylwester Nawrocki
Samsung Poland R&D Center

             reply	other threads:[~2011-07-28 17:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28 17:04 Sylwester Nawrocki [this message]
2011-08-16 22:25 ` RFC: Negotiating frame buffer size between sensor subdevs and bridge devices Sakari Ailus
2011-08-17 17:43   ` Guennadi Liakhovetski
2011-08-20 21:10     ` Sylwester Nawrocki
2011-08-17 20:22   ` Sylwester Nawrocki
2011-08-18 20:32     ` Sakari Ailus
2011-08-19 13:13       ` Sylwester Nawrocki

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=4E31968B.9080603@samsung.com \
    --to=s.nawrocki@samsung.com \
    --cc=linux-media@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).