All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Figa <tfiga@chromium.org>
To: ping-chung.chen@intel.com,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	sylwester.nawrocki@gmail.com
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	"Yeh, Andy" <andy.yeh@intel.com>, "Lai, Jim" <jim.lai@intel.com>,
	Grant Grundler <grundler@chromium.org>,
	"Mani, Rajmohan" <rajmohan.mani@intel.com>
Subject: Re: [PATCH v5] media: imx208: Add imx208 camera sensor driver
Date: Thu, 20 Sep 2018 17:51:55 +0900	[thread overview]
Message-ID: <CAAFQd5D=ze1nSCXwUxOm58+oiWNwuZDS5PvuR+xtNH0=YhA7NQ@mail.gmail.com> (raw)
In-Reply-To: <1533712560-17357-1-git-send-email-ping-chung.chen@intel.com>

[+Laurent and Sylwester]

On Wed, Aug 8, 2018 at 4:08 PM Ping-chung Chen
<ping-chung.chen@intel.com> wrote:
[snip]
> +
> +/* Digital gain control */
> +#define IMX208_REG_GR_DIGITAL_GAIN     0x020e
> +#define IMX208_REG_R_DIGITAL_GAIN      0x0210
> +#define IMX208_REG_B_DIGITAL_GAIN      0x0212
> +#define IMX208_REG_GB_DIGITAL_GAIN     0x0214
> +#define IMX208_DGTL_GAIN_MIN           0
> +#define IMX208_DGTL_GAIN_MAX           4096
> +#define IMX208_DGTL_GAIN_DEFAULT       0x100
> +#define IMX208_DGTL_GAIN_STEP           1
> +
[snip]
> +/* Initialize control handlers */
> +static int imx208_init_controls(struct imx208 *imx208)
> +{
[snip]
> +       v4l2_ctrl_new_std(ctrl_hdlr, &imx208_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
> +                         IMX208_DGTL_GAIN_MIN, IMX208_DGTL_GAIN_MAX,
> +                         IMX208_DGTL_GAIN_STEP,
> +                         IMX208_DGTL_GAIN_DEFAULT);

We have a problem here. The sensor supports only a discrete range of
values here - {1, 2, 4, 8, 16} (multiplied by 256, since the value is
fixed point). This makes it possible for the userspace to set values
that are not allowed by the sensor specification and also leaves no
way to enumerate the supported values.

I can see two solutions here:

1) Define the control range from 0 to 4 and treat it as an exponent of
2, so that the value for the sensor becomes (1 << val) * 256.
(Suggested by Sakari offline.)

This approach has the problem of losing the original unit (and scale)
of the value.

2) Use an integer menu control, which reports only the supported
discrete values - {1, 2, 4, 8, 16}.

With this approach, userspace can enumerate the real gain values, but
we would either need to introduce a new control (e.g.
V4L2_CID_DIGITAL_GAIN_DISCRETE) or abuse the specification and
register V4L2_CID_DIGITAL_GAIN as an integer menu.

Any opinions or better ideas?

Best regards,
Tomasz

  parent reply	other threads:[~2018-09-20 14:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-08  7:16 [PATCH v5] media: imx208: Add imx208 camera sensor driver Ping-chung Chen
2018-09-14 11:41 ` Sakari Ailus
2018-09-17 22:52   ` Grant Grundler
2018-09-18 10:52     ` Sakari Ailus
2018-09-20  8:51 ` Tomasz Figa [this message]
2018-09-20 16:49   ` Grant Grundler
2018-09-20 20:16     ` Sylwester Nawrocki
2018-09-20 21:00       ` Laurent Pinchart
2018-09-21  7:23         ` Helmut Grohne
2018-09-28 13:49           ` Laurent Pinchart
2018-10-01 10:50             ` Helmut Grohne
2018-10-01 12:04               ` Philippe De Muyter
2018-09-20 20:56   ` Sakari Ailus
2018-09-20 21:12     ` Laurent Pinchart
2018-09-20 21:55       ` Ricardo Ribalda Delgado
2018-09-21  7:06         ` Chen, Ping-chung
2018-09-21  7:08         ` Chen, Ping-chung
2018-09-25  9:25           ` Sakari Ailus
2018-09-25 10:17             ` Chen, Ping-chung
2018-09-25 21:54               ` Sakari Ailus
2018-09-26  2:27                 ` Chen, Ping-chung
2018-09-26 10:11                   ` Sakari Ailus
2018-09-26 15:19                     ` Yeh, Andy
2018-09-27  3:19                       ` Chen, Ping-chung
2018-10-04 15:57                         ` Sakari Ailus
2021-04-22  7:21                           ` Tu, ShawnX

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='CAAFQd5D=ze1nSCXwUxOm58+oiWNwuZDS5PvuR+xtNH0=YhA7NQ@mail.gmail.com' \
    --to=tfiga@chromium.org \
    --cc=andy.yeh@intel.com \
    --cc=grundler@chromium.org \
    --cc=jim.lai@intel.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=ping-chung.chen@intel.com \
    --cc=rajmohan.mani@intel.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sylwester.nawrocki@gmail.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.