* [PATCH] mt9t031: use platform power hook
@ 2009-04-02 9:56 Guennadi Liakhovetski
2009-04-02 17:30 ` Darius Augulis
0 siblings, 1 reply; 3+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-02 9:56 UTC (permalink / raw)
To: Linux Media Mailing List
Use platform power hook to turn the camera on and off.
Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
---
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c
index 23f9ce9..2b0927b 100644
--- a/drivers/media/video/mt9t031.c
+++ b/drivers/media/video/mt9t031.c
@@ -141,8 +141,19 @@ static int get_shutter(struct soc_camera_device *icd, u32 *data)
static int mt9t031_init(struct soc_camera_device *icd)
{
+ struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
+ struct soc_camera_link *icl = mt9t031->client->dev.platform_data;
int ret;
+ if (icl->power) {
+ ret = icl->power(&mt9t031->client->dev, 1);
+ if (ret < 0) {
+ dev_err(icd->vdev->parent,
+ "Platform failed to power-on the camera.\n");
+ return ret;
+ }
+ }
+
/* Disable chip output, synchronous option update */
ret = reg_write(icd, MT9T031_RESET, 1);
if (ret >= 0)
@@ -150,13 +161,23 @@ static int mt9t031_init(struct soc_camera_device *icd)
if (ret >= 0)
ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
+ if (ret < 0 && icl->power)
+ icl->power(&mt9t031->client->dev, 0);
+
return ret >= 0 ? 0 : -EIO;
}
static int mt9t031_release(struct soc_camera_device *icd)
{
+ struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
+ struct soc_camera_link *icl = mt9t031->client->dev.platform_data;
+
/* Disable the chip */
reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
+
+ if (icl->power)
+ icl->power(&mt9t031->client->dev, 0);
+
return 0;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mt9t031: use platform power hook
2009-04-02 9:56 [PATCH] mt9t031: use platform power hook Guennadi Liakhovetski
@ 2009-04-02 17:30 ` Darius Augulis
2009-04-02 17:36 ` Guennadi Liakhovetski
0 siblings, 1 reply; 3+ messages in thread
From: Darius Augulis @ 2009-04-02 17:30 UTC (permalink / raw)
To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List
Guennadi Liakhovetski wrote:
> Use platform power hook to turn the camera on and off.
>
> Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
> ---
> diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c
> index 23f9ce9..2b0927b 100644
> --- a/drivers/media/video/mt9t031.c
> +++ b/drivers/media/video/mt9t031.c
> @@ -141,8 +141,19 @@ static int get_shutter(struct soc_camera_device *icd, u32 *data)
>
> static int mt9t031_init(struct soc_camera_device *icd)
> {
> + struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
> + struct soc_camera_link *icl = mt9t031->client->dev.platform_data;
> int ret;
>
> + if (icl->power) {
> + ret = icl->power(&mt9t031->client->dev, 1);
> + if (ret < 0) {
> + dev_err(icd->vdev->parent,
> + "Platform failed to power-on the camera.\n");
> + return ret;
> + }
> + }
probably you would have to call icl->reset there too?
I guess this camera sensor does have a reset pin?
> +
> /* Disable chip output, synchronous option update */
> ret = reg_write(icd, MT9T031_RESET, 1);
> if (ret >= 0)
> @@ -150,13 +161,23 @@ static int mt9t031_init(struct soc_camera_device *icd)
> if (ret >= 0)
> ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
>
> + if (ret < 0 && icl->power)
> + icl->power(&mt9t031->client->dev, 0);
> +
> return ret >= 0 ? 0 : -EIO;
> }
>
> static int mt9t031_release(struct soc_camera_device *icd)
> {
> + struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
> + struct soc_camera_link *icl = mt9t031->client->dev.platform_data;
> +
> /* Disable the chip */
> reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
> +
> + if (icl->power)
> + icl->power(&mt9t031->client->dev, 0);
> +
> return 0;
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mt9t031: use platform power hook
2009-04-02 17:30 ` Darius Augulis
@ 2009-04-02 17:36 ` Guennadi Liakhovetski
0 siblings, 0 replies; 3+ messages in thread
From: Guennadi Liakhovetski @ 2009-04-02 17:36 UTC (permalink / raw)
To: Darius Augulis; +Cc: Linux Media Mailing List
On Thu, 2 Apr 2009, Darius Augulis wrote:
> Guennadi Liakhovetski wrote:
> > Use platform power hook to turn the camera on and off.
> >
> > Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
> > ---
> > diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c
> > index 23f9ce9..2b0927b 100644
> > --- a/drivers/media/video/mt9t031.c
> > +++ b/drivers/media/video/mt9t031.c
> > @@ -141,8 +141,19 @@ static int get_shutter(struct soc_camera_device *icd,
> > u32 *data)
> > static int mt9t031_init(struct soc_camera_device *icd)
> > {
> > + struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
> > + struct soc_camera_link *icl = mt9t031->client->dev.platform_data;
> > int ret;
> > + if (icl->power) {
> > + ret = icl->power(&mt9t031->client->dev, 1);
> > + if (ret < 0) {
> > + dev_err(icd->vdev->parent,
> > + "Platform failed to power-on the camera.\n");
> > + return ret;
> > + }
> > + }
>
> probably you would have to call icl->reset there too?
> I guess this camera sensor does have a reset pin?
Reset is not implemented on this board, and I do not want to implement
something that noone can test ATM.
Thanks
Guennadi
>
>
> > +
> > /* Disable chip output, synchronous option update */
> > ret = reg_write(icd, MT9T031_RESET, 1);
> > if (ret >= 0)
> > @@ -150,13 +161,23 @@ static int mt9t031_init(struct soc_camera_device *icd)
> > if (ret >= 0)
> > ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
> > + if (ret < 0 && icl->power)
> > + icl->power(&mt9t031->client->dev, 0);
> > +
> > return ret >= 0 ? 0 : -EIO;
> > }
> > static int mt9t031_release(struct soc_camera_device *icd)
> > {
> > + struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
> > + struct soc_camera_link *icl = mt9t031->client->dev.platform_data;
> > +
> > /* Disable the chip */
> > reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2);
> > +
> > + if (icl->power)
> > + icl->power(&mt9t031->client->dev, 0);
> > +
> > return 0;
> > }
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-media" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
>
>
---
Guennadi Liakhovetski, Ph.D.
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-04-02 17:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-02 9:56 [PATCH] mt9t031: use platform power hook Guennadi Liakhovetski
2009-04-02 17:30 ` Darius Augulis
2009-04-02 17:36 ` Guennadi Liakhovetski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox