All of lore.kernel.org
 help / color / mirror / Atom feed
* exposing a large-ish calibration table through V4L2?
@ 2018-02-14 12:09 Florian Echtler
  2018-02-14 12:13 ` Hans Verkuil
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Echtler @ 2018-02-14 12:09 UTC (permalink / raw)
  To: Linux Media Mailing List, Hans Verkuil


[-- Attachment #1.1: Type: text/plain, Size: 796 bytes --]

Hello Hans,

I've picked up work on the sur40 driver again recently. There is one major
feature left that is currently unsupported by the Linux driver, which is the
hardware-based calibration.

The internal device memory contains a table with two bytes for each sensor pixel
(i.e. 960x540x2 = 1036800 bytes) that basically provide individual black and
white levels per-pixel that are used in preprocessing. The table can either be
set externally, or the sensor can be covered with a black/white surface and a
custom command triggers an internal calibration.

AFAICT the usual V4L2 controls are unsuitable for this sort of data; do you have
any suggestions on how to approach this? Maybe something like a custom IOCTL?

Best regards, Florian
-- 
SENT FROM MY DEC VT50 TERMINAL


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: exposing a large-ish calibration table through V4L2?
  2018-02-14 12:09 exposing a large-ish calibration table through V4L2? Florian Echtler
@ 2018-02-14 12:13 ` Hans Verkuil
  2018-02-14 12:27   ` Florian Echtler
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Verkuil @ 2018-02-14 12:13 UTC (permalink / raw)
  To: Florian Echtler, Linux Media Mailing List

Hi Florian,

On 14/02/18 13:09, Florian Echtler wrote:
> Hello Hans,
> 
> I've picked up work on the sur40 driver again recently. There is one major
> feature left that is currently unsupported by the Linux driver, which is the
> hardware-based calibration.
> 
> The internal device memory contains a table with two bytes for each sensor pixel
> (i.e. 960x540x2 = 1036800 bytes) that basically provide individual black and
> white levels per-pixel that are used in preprocessing. The table can either be
> set externally, or the sensor can be covered with a black/white surface and a
> custom command triggers an internal calibration.
> 
> AFAICT the usual V4L2 controls are unsuitable for this sort of data; do you have
> any suggestions on how to approach this? Maybe something like a custom IOCTL?

So the table has a fixed size?

You can use array controls for that, a V4L2_CTRL_TYPE_U16 in a two-dimensional array
would do it.

See https://hverkuil.home.xs4all.nl/spec/uapi/v4l/vidioc-queryctrl.html for more
information on how this works.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: exposing a large-ish calibration table through V4L2?
  2018-02-14 12:13 ` Hans Verkuil
@ 2018-02-14 12:27   ` Florian Echtler
  2018-02-14 13:03     ` Hans Verkuil
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Echtler @ 2018-02-14 12:27 UTC (permalink / raw)
  To: Hans Verkuil, Linux Media Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 1183 bytes --]

Hello Hans,

On 14.02.2018 13:13, Hans Verkuil wrote:
> 
> On 14/02/18 13:09, Florian Echtler wrote:
>>
>> The internal device memory contains a table with two bytes for each sensor pixel
>> (i.e. 960x540x2 = 1036800 bytes) that basically provide individual black and
>> white levels per-pixel that are used in preprocessing. The table can either be
>> set externally, or the sensor can be covered with a black/white surface and a
>> custom command triggers an internal calibration.
>>
>> AFAICT the usual V4L2 controls are unsuitable for this sort of data; do you have
>> any suggestions on how to approach this? Maybe something like a custom IOCTL?
> 
> So the table has a fixed size?
> You can use array controls for that, a V4L2_CTRL_TYPE_U16 in a two-dimensional array
> would do it.

Good to know, thanks.

> See https://hverkuil.home.xs4all.nl/spec/uapi/v4l/vidioc-queryctrl.html for more
> information on how this works.

This means I have to implement QUERY_EXT_CTRL, G_EXT_CTRLS and S_EXT_CTRLS,
correct? Will this work in parallel to the "regular" controls that use the
control framework?

Best, Florian
-- 
SENT FROM MY DEC VT50 TERMINAL


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: exposing a large-ish calibration table through V4L2?
  2018-02-14 12:27   ` Florian Echtler
@ 2018-02-14 13:03     ` Hans Verkuil
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Verkuil @ 2018-02-14 13:03 UTC (permalink / raw)
  To: Florian Echtler, Linux Media Mailing List

On 14/02/18 13:27, Florian Echtler wrote:
> Hello Hans,
> 
> On 14.02.2018 13:13, Hans Verkuil wrote:
>>
>> On 14/02/18 13:09, Florian Echtler wrote:
>>>
>>> The internal device memory contains a table with two bytes for each sensor pixel
>>> (i.e. 960x540x2 = 1036800 bytes) that basically provide individual black and
>>> white levels per-pixel that are used in preprocessing. The table can either be
>>> set externally, or the sensor can be covered with a black/white surface and a
>>> custom command triggers an internal calibration.
>>>
>>> AFAICT the usual V4L2 controls are unsuitable for this sort of data; do you have
>>> any suggestions on how to approach this? Maybe something like a custom IOCTL?
>>
>> So the table has a fixed size?
>> You can use array controls for that, a V4L2_CTRL_TYPE_U16 in a two-dimensional array
>> would do it.
> 
> Good to know, thanks.
> 
>> See https://hverkuil.home.xs4all.nl/spec/uapi/v4l/vidioc-queryctrl.html for more
>> information on how this works.
> 
> This means I have to implement QUERY_EXT_CTRL, G_EXT_CTRLS and S_EXT_CTRLS,
> correct? Will this work in parallel to the "regular" controls that use the
> control framework?

No, just use the control framework. You need to make a custom control that is
specific to your driver

So reserve a range for your driver in include/uapi/linux/v4l2-controls.h
(search for 'USER-class private control IDs'). Then you can define a control
ID. The next step is to configure the control:

static const struct v4l2_ctrl_config cal_table_control = {
        .ops = &cal_ctrl_ops,
        .id = V4L2_CID_SUR40_CAL_TABLE,
        .name = "Calibration Table",
        .type = V4L2_CTRL_TYPE_U16,
        .max = 0xffff,
        .step = 1,
        .def = 0,
        .dims = { 960, 540 },
};

And register it with a control handler:

v4l2_ctrl_new_custom(hdl, &cal_table_control, NULL);

See e.g. drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c and the DETECT_MD controls.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-14 13:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 12:09 exposing a large-ish calibration table through V4L2? Florian Echtler
2018-02-14 12:13 ` Hans Verkuil
2018-02-14 12:27   ` Florian Echtler
2018-02-14 13:03     ` Hans Verkuil

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.