aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cafe_ccic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cafe_ccic.c')
-rw-r--r--drivers/media/video/cafe_ccic.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 684d817ccfe3..dc6e16c2b83b 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -505,6 +505,8 @@ static struct i2c_algorithm cafe_smbus_algo = {
505 505
506/* Somebody is on the bus */ 506/* Somebody is on the bus */
507static int cafe_cam_init(struct cafe_camera *cam); 507static int cafe_cam_init(struct cafe_camera *cam);
508static void cafe_ctlr_stop_dma(struct cafe_camera *cam);
509static void cafe_ctlr_power_down(struct cafe_camera *cam);
508 510
509static int cafe_smbus_attach(struct i2c_client *client) 511static int cafe_smbus_attach(struct i2c_client *client)
510{ 512{
@@ -513,7 +515,6 @@ static int cafe_smbus_attach(struct i2c_client *client)
513 /* 515 /*
514 * Don't talk to chips we don't recognize. 516 * Don't talk to chips we don't recognize.
515 */ 517 */
516 cam_err(cam, "smbus_attach id = %d\n", client->driver->id);
517 if (client->driver->id == I2C_DRIVERID_OV7670) { 518 if (client->driver->id == I2C_DRIVERID_OV7670) {
518 cam->sensor = client; 519 cam->sensor = client;
519 return cafe_cam_init(cam); 520 return cafe_cam_init(cam);
@@ -525,8 +526,13 @@ static int cafe_smbus_detach(struct i2c_client *client)
525{ 526{
526 struct cafe_camera *cam = i2c_get_adapdata(client->adapter); 527 struct cafe_camera *cam = i2c_get_adapdata(client->adapter);
527 528
528 if (cam->sensor == client) 529 if (cam->sensor == client) {
530 cafe_ctlr_stop_dma(cam);
531 cafe_ctlr_power_down(cam);
532 cam_err(cam, "lost the sensor!\n");
529 cam->sensor = NULL; /* Bummer, no camera */ 533 cam->sensor = NULL; /* Bummer, no camera */
534 cam->state = S_NOTREADY;
535 }
530 return 0; 536 return 0;
531} 537}
532 538
@@ -774,7 +780,7 @@ static void cafe_ctlr_power_up(struct cafe_camera *cam)
774 * wiring). Control 0 is reset - set to 1 to operate. 780 * wiring). Control 0 is reset - set to 1 to operate.
775 * Control 1 is power down, set to 0 to operate. 781 * Control 1 is power down, set to 0 to operate.
776 */ 782 */
777 cafe_reg_write(cam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C1); 783 cafe_reg_write(cam, REG_GPR, GPR_C1EN|GPR_C0EN); /* pwr up, reset */
778 mdelay(1); /* Marvell says 1ms will do it */ 784 mdelay(1); /* Marvell says 1ms will do it */
779 cafe_reg_write(cam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C0); 785 cafe_reg_write(cam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C0);
780 mdelay(1); /* Enough? */ 786 mdelay(1); /* Enough? */
@@ -1468,8 +1474,11 @@ static int cafe_v4l_release(struct inode *inode, struct file *filp)
1468 cafe_free_sio_buffers(cam); 1474 cafe_free_sio_buffers(cam);
1469 cam->owner = NULL; 1475 cam->owner = NULL;
1470 } 1476 }
1471 if (cam->users == 0) 1477 if (cam->users == 0) {
1472 cafe_ctlr_power_down(cam); 1478 cafe_ctlr_power_down(cam);
1479 if (! alloc_bufs_at_load)
1480 cafe_free_dma_bufs(cam);
1481 }
1473 mutex_unlock(&cam->s_mutex); 1482 mutex_unlock(&cam->s_mutex);
1474 return 0; 1483 return 0;
1475} 1484}