All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: javier Martin <javier.martin@vista-silicon.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	carlighting@yahoo.co.nz, beagleboard@googlegroups.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor.
Date: Tue, 24 May 2011 10:39:58 +0200	[thread overview]
Message-ID: <201105241039.58428.laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <BANLkTinKgj-HmKwAWN-e6+8kj6ZRC4WJgg@mail.gmail.com>

Hi Javier,

On Tuesday 24 May 2011 10:31:46 javier Martin wrote:
> On 23 May 2011 11:03, Laurent Pinchart wrote:
> > On Saturday 21 May 2011 17:29:18 Guennadi Liakhovetski wrote:
> >> On Fri, 20 May 2011, Javier Martin wrote:
> > [snip]
> > 
> >> > diff --git a/drivers/media/video/mt9p031.c
> >> > b/drivers/media/video/mt9p031.c new file mode 100644
> >> > index 0000000..e406b64
> >> > --- /dev/null
> >> > +++ b/drivers/media/video/mt9p031.c
> > 
> > [snip]
> > 
> >> > +}
> >> > +
> >> > +static int mt9p031_power_on(struct mt9p031 *mt9p031)
> >> > +{
> >> > +   int ret;
> >> > +
> >> > +   /* turn on VDD_IO */
> >> > +   ret = regulator_enable(mt9p031->reg_2v8);
> >> > +   if (ret) {
> >> > +           pr_err("Failed to enable 2.8v regulator: %d\n", ret);
> >> 
> >> dev_err()
> >> 
> >> > +           return ret;
> >> > +   }
> >> > +   if (mt9p031->pdata->set_xclk)
> >> > +           mt9p031->pdata->set_xclk(&mt9p031->subdev, 54000000);
> > 
> > Can you make 54000000 a #define at the beginning of the file ?
> > 
> > You should soft-reset the chip here by calling mt9p031_reset().
> 
> If I do this, I would be force to cache some registers and restart
> them. I've tried to do this but I don't know what is failing that
> there are some artifacts consisting on horizontal black lines in the
> image.

You need to cache registers anyway, as the chip will be reset to default 
values by the core power cycling. And as I'm writing those lines I realize 
that you don't power cycle reg_1v8. This needs to be done to save power.

> Please, let me push this to mainline without this feature as a first
> step, since I'll have to spend some assigned to another project.

Power handling is an important feature. I don't think the driver is ready 
without it. 

> [snip]
> 
> >> > + */
> >> > +static int mt9p031_video_probe(struct i2c_client *client)
> >> > +{
> >> > +   s32 data;
> >> > +   int ret;
> >> > +
> >> > +   /* Read out the chip version register */
> >> > +   data = reg_read(client, MT9P031_CHIP_VERSION);
> >> > +   if (data != MT9P031_CHIP_VERSION_VALUE) {
> >> > +           dev_err(&client->dev,
> >> > +                   "No MT9P031 chip detected, register read %x\n",
> >> > data); +           return -ENODEV;
> >> > +   }
> >> > +
> >> > +   dev_info(&client->dev, "Detected a MT9P031 chip ID %x\n", data);
> >> > +
> >> > +   ret = mt9p031_reset(client);
> >> > +   if (ret < 0)
> >> > +           dev_err(&client->dev, "Failed to initialise the
> >> > camera\n");
> > 
> > If you move the soft-reset operation to mt9p031_power_on(), you don't
> > need to call it here.
> 
> The reason for this is the same as before. I haven't still been able
> to success on restarting registers and getting everything to work
> fine.
> It would be great if you allowed me to push this as it is as an
> intermediate step.

Sorry, but I'd like to see power management properly implemented before the 
driver hits mainline. Other less important features (such as exposure/gain 
controls for instance) can be missing, but proper power management is 
important.

> [snip]
> 
> >> > +   mt9p031->rect.width     = MT9P031_MAX_WIDTH;
> >> > +   mt9p031->rect.height    = MT9P031_MAX_HEIGHT;
> >> > +
> >> > +   mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
> >> > +
> >> > +   mt9p031->format.width = MT9P031_MAX_WIDTH;
> >> > +   mt9p031->format.height = MT9P031_MAX_HEIGHT;
> >> > +   mt9p031->format.field = V4L2_FIELD_NONE;
> >> > +   mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB;
> >> > +
> >> > +   mt9p031->xskip = 1;
> >> > +   mt9p031->yskip = 1;
> >> > +
> >> > +   mt9p031->reg_1v8 = regulator_get(NULL, "cam_1v8");
> >> > +   if (IS_ERR(mt9p031->reg_1v8)) {
> >> > +           ret = PTR_ERR(mt9p031->reg_1v8);
> >> > +           pr_err("Failed 1.8v regulator: %d\n", ret);
> >> 
> >> dev_err()
> >> 
> >> > +           goto e1v8;
> >> > +   }
> > 
> > The driver can be used with boards where either or both of the 1.8V and
> > 2.8V supplies are always on, thus not connected to any regulator. I'm
> > not sure how that's usually handled, if board code should define an
> > "always-on" power supply, or if the driver shouldn't fail when no
> > regulator is present. In any case, this must be handled.
> 
> I think board code should define an "always-on" power supply.

Fine with me. How is that done BTW ?

> >> > +
> >> > +   mt9p031->reg_2v8 = regulator_get(NULL, "cam_2v8");
> >> > +   if (IS_ERR(mt9p031->reg_2v8)) {
> >> > +           ret = PTR_ERR(mt9p031->reg_2v8);
> >> > +           pr_err("Failed 2.8v regulator: %d\n", ret);
> >> 
> >> ditto
> >> 
> >> > +           goto e2v8;
> >> > +   }
> >> > +   /* turn on core */
> >> > +   ret = regulator_enable(mt9p031->reg_1v8);
> >> > +   if (ret) {
> >> > +           pr_err("Failed to enable 1.8v regulator: %d\n", ret);
> >> 
> >> ditto
> >> 
> >> > +           goto e1v8en;
> >> > +   }
> >> > +   return 0;
> > 
> > Why do you leave core power on at the end of probe() ? You should only
> > turn it on when needed.
> 
> Just as I said, because restarting registers does not work yet.

-- 
Regards,

Laurent Pinchart

WARNING: multiple messages have this Message-ID (diff)
From: laurent.pinchart@ideasonboard.com (Laurent Pinchart)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor.
Date: Tue, 24 May 2011 10:39:58 +0200	[thread overview]
Message-ID: <201105241039.58428.laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <BANLkTinKgj-HmKwAWN-e6+8kj6ZRC4WJgg@mail.gmail.com>

Hi Javier,

On Tuesday 24 May 2011 10:31:46 javier Martin wrote:
> On 23 May 2011 11:03, Laurent Pinchart wrote:
> > On Saturday 21 May 2011 17:29:18 Guennadi Liakhovetski wrote:
> >> On Fri, 20 May 2011, Javier Martin wrote:
> > [snip]
> > 
> >> > diff --git a/drivers/media/video/mt9p031.c
> >> > b/drivers/media/video/mt9p031.c new file mode 100644
> >> > index 0000000..e406b64
> >> > --- /dev/null
> >> > +++ b/drivers/media/video/mt9p031.c
> > 
> > [snip]
> > 
> >> > +}
> >> > +
> >> > +static int mt9p031_power_on(struct mt9p031 *mt9p031)
> >> > +{
> >> > +   int ret;
> >> > +
> >> > +   /* turn on VDD_IO */
> >> > +   ret = regulator_enable(mt9p031->reg_2v8);
> >> > +   if (ret) {
> >> > +           pr_err("Failed to enable 2.8v regulator: %d\n", ret);
> >> 
> >> dev_err()
> >> 
> >> > +           return ret;
> >> > +   }
> >> > +   if (mt9p031->pdata->set_xclk)
> >> > +           mt9p031->pdata->set_xclk(&mt9p031->subdev, 54000000);
> > 
> > Can you make 54000000 a #define at the beginning of the file ?
> > 
> > You should soft-reset the chip here by calling mt9p031_reset().
> 
> If I do this, I would be force to cache some registers and restart
> them. I've tried to do this but I don't know what is failing that
> there are some artifacts consisting on horizontal black lines in the
> image.

You need to cache registers anyway, as the chip will be reset to default 
values by the core power cycling. And as I'm writing those lines I realize 
that you don't power cycle reg_1v8. This needs to be done to save power.

> Please, let me push this to mainline without this feature as a first
> step, since I'll have to spend some assigned to another project.

Power handling is an important feature. I don't think the driver is ready 
without it. 

> [snip]
> 
> >> > + */
> >> > +static int mt9p031_video_probe(struct i2c_client *client)
> >> > +{
> >> > +   s32 data;
> >> > +   int ret;
> >> > +
> >> > +   /* Read out the chip version register */
> >> > +   data = reg_read(client, MT9P031_CHIP_VERSION);
> >> > +   if (data != MT9P031_CHIP_VERSION_VALUE) {
> >> > +           dev_err(&client->dev,
> >> > +                   "No MT9P031 chip detected, register read %x\n",
> >> > data); +           return -ENODEV;
> >> > +   }
> >> > +
> >> > +   dev_info(&client->dev, "Detected a MT9P031 chip ID %x\n", data);
> >> > +
> >> > +   ret = mt9p031_reset(client);
> >> > +   if (ret < 0)
> >> > +           dev_err(&client->dev, "Failed to initialise the
> >> > camera\n");
> > 
> > If you move the soft-reset operation to mt9p031_power_on(), you don't
> > need to call it here.
> 
> The reason for this is the same as before. I haven't still been able
> to success on restarting registers and getting everything to work
> fine.
> It would be great if you allowed me to push this as it is as an
> intermediate step.

Sorry, but I'd like to see power management properly implemented before the 
driver hits mainline. Other less important features (such as exposure/gain 
controls for instance) can be missing, but proper power management is 
important.

> [snip]
> 
> >> > +   mt9p031->rect.width     = MT9P031_MAX_WIDTH;
> >> > +   mt9p031->rect.height    = MT9P031_MAX_HEIGHT;
> >> > +
> >> > +   mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
> >> > +
> >> > +   mt9p031->format.width = MT9P031_MAX_WIDTH;
> >> > +   mt9p031->format.height = MT9P031_MAX_HEIGHT;
> >> > +   mt9p031->format.field = V4L2_FIELD_NONE;
> >> > +   mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB;
> >> > +
> >> > +   mt9p031->xskip = 1;
> >> > +   mt9p031->yskip = 1;
> >> > +
> >> > +   mt9p031->reg_1v8 = regulator_get(NULL, "cam_1v8");
> >> > +   if (IS_ERR(mt9p031->reg_1v8)) {
> >> > +           ret = PTR_ERR(mt9p031->reg_1v8);
> >> > +           pr_err("Failed 1.8v regulator: %d\n", ret);
> >> 
> >> dev_err()
> >> 
> >> > +           goto e1v8;
> >> > +   }
> > 
> > The driver can be used with boards where either or both of the 1.8V and
> > 2.8V supplies are always on, thus not connected to any regulator. I'm
> > not sure how that's usually handled, if board code should define an
> > "always-on" power supply, or if the driver shouldn't fail when no
> > regulator is present. In any case, this must be handled.
> 
> I think board code should define an "always-on" power supply.

Fine with me. How is that done BTW ?

> >> > +
> >> > +   mt9p031->reg_2v8 = regulator_get(NULL, "cam_2v8");
> >> > +   if (IS_ERR(mt9p031->reg_2v8)) {
> >> > +           ret = PTR_ERR(mt9p031->reg_2v8);
> >> > +           pr_err("Failed 2.8v regulator: %d\n", ret);
> >> 
> >> ditto
> >> 
> >> > +           goto e2v8;
> >> > +   }
> >> > +   /* turn on core */
> >> > +   ret = regulator_enable(mt9p031->reg_1v8);
> >> > +   if (ret) {
> >> > +           pr_err("Failed to enable 1.8v regulator: %d\n", ret);
> >> 
> >> ditto
> >> 
> >> > +           goto e1v8en;
> >> > +   }
> >> > +   return 0;
> > 
> > Why do you leave core power on at the end of probe() ? You should only
> > turn it on when needed.
> 
> Just as I said, because restarting registers does not work yet.

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2011-05-24  8:39 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 13:47 [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor Javier Martin
2011-05-20 13:47 ` Javier Martin
2011-05-20 13:47 ` [PATCH v2 2/2] OMAP3BEAGLE: Add support for mt9p031 sensor driver Javier Martin
2011-05-20 13:47   ` Javier Martin
2011-05-20 15:57   ` [beagleboard] " Koen Kooi
2011-05-20 15:57     ` Koen Kooi
2011-05-23  7:01     ` javier Martin
2011-05-23  7:01       ` javier Martin
2011-05-23  8:00       ` Laurent Pinchart
2011-05-23  8:00         ` Laurent Pinchart
2011-05-23  8:55         ` Koen Kooi
2011-05-23  8:55           ` Koen Kooi
2011-05-23  9:14           ` Laurent Pinchart
2011-05-23  9:14             ` Laurent Pinchart
2011-05-22 13:49   ` Igor Grinberg
2011-05-22 13:49     ` Igor Grinberg
2011-05-23  7:25     ` javier Martin
2011-05-23  7:25       ` javier Martin
2011-05-23  7:25       ` javier Martin
2011-05-23  7:47       ` Laurent Pinchart
2011-05-23  7:47         ` Laurent Pinchart
2011-05-23 17:03         ` Igor Grinberg
2011-05-23 17:03           ` Igor Grinberg
2011-05-21 12:55 ` [PATCH v2 1/2] MT9P031: Add support for Aptina mt9p031 sensor Mauro Carvalho Chehab
2011-05-21 12:55   ` Mauro Carvalho Chehab
2011-05-22 20:41   ` Laurent Pinchart
2011-05-22 20:41     ` Laurent Pinchart
2011-05-21 15:29 ` Guennadi Liakhovetski
2011-05-21 15:29   ` Guennadi Liakhovetski
2011-05-23  8:20   ` javier Martin
2011-05-23  8:20     ` javier Martin
2011-05-23  8:48     ` Guennadi Liakhovetski
2011-05-23  8:48       ` Guennadi Liakhovetski
2011-05-23  9:08       ` Laurent Pinchart
2011-05-23  9:08         ` Laurent Pinchart
2011-05-23  9:03   ` Laurent Pinchart
2011-05-23  9:03     ` Laurent Pinchart
2011-05-23  9:26     ` Guennadi Liakhovetski
2011-05-23  9:26       ` Guennadi Liakhovetski
2011-05-24  8:31     ` javier Martin
2011-05-24  8:31       ` javier Martin
2011-05-24  8:39       ` Laurent Pinchart [this message]
2011-05-24  8:39         ` Laurent Pinchart
2011-05-24  8:56         ` javier Martin
2011-05-24  8:56           ` javier Martin
2011-05-24  8:58           ` Laurent Pinchart
2011-05-24  8:58             ` Laurent Pinchart
2011-05-23  3:01 Chris Rodley
2011-05-23  6:54 ` javier Martin
2011-05-24  5:03 Chris Rodley
2011-05-25  3:45 Chris Rodley
2011-05-25  7:00 ` javier Martin
2011-05-25  7:00   ` javier Martin

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=201105241039.58428.laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=beagleboard@googlegroups.com \
    --cc=carlighting@yahoo.co.nz \
    --cc=g.liakhovetski@gmx.de \
    --cc=javier.martin@vista-silicon.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --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 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.