]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (11347): mt9t031: use platform power hook
authorGuennadi Liakhovetski <lg@denx.de>
Fri, 3 Apr 2009 13:14:02 +0000 (10:14 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 7 Apr 2009 00:43:57 +0000 (21:43 -0300)
Use platform power hook to turn the camera on and off.

Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/mt9t031.c

index 23f9ce9d67ef688ee10158fb4543417992d1fa06..2b0927bfd217b1226366f370f6e09d4ee5c57dde 100644 (file)
@@ -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;
 }