aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/soc_camera/mt9m001.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9m001.c')
-rw-r--r--drivers/media/i2c/soc_camera/mt9m001.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9m001.c b/drivers/media/i2c/soc_camera/mt9m001.c
index 19f8a07764f9..bcdc86175549 100644
--- a/drivers/media/i2c/soc_camera/mt9m001.c
+++ b/drivers/media/i2c/soc_camera/mt9m001.c
@@ -23,7 +23,7 @@
23/* 23/*
24 * mt9m001 i2c address 0x5d 24 * mt9m001 i2c address 0x5d
25 * The platform has to define struct i2c_board_info objects and link to them 25 * The platform has to define struct i2c_board_info objects and link to them
26 * from struct soc_camera_link 26 * from struct soc_camera_host_desc
27 */ 27 */
28 28
29/* mt9m001 selected register addresses */ 29/* mt9m001 selected register addresses */
@@ -380,9 +380,9 @@ static int mt9m001_s_register(struct v4l2_subdev *sd,
380static int mt9m001_s_power(struct v4l2_subdev *sd, int on) 380static int mt9m001_s_power(struct v4l2_subdev *sd, int on)
381{ 381{
382 struct i2c_client *client = v4l2_get_subdevdata(sd); 382 struct i2c_client *client = v4l2_get_subdevdata(sd);
383 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 383 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
384 384
385 return soc_camera_set_power(&client->dev, icl, on); 385 return soc_camera_set_power(&client->dev, ssdd, on);
386} 386}
387 387
388static int mt9m001_g_volatile_ctrl(struct v4l2_ctrl *ctrl) 388static int mt9m001_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
@@ -482,7 +482,7 @@ static int mt9m001_s_ctrl(struct v4l2_ctrl *ctrl)
482 * Interface active, can use i2c. If it fails, it can indeed mean, that 482 * Interface active, can use i2c. If it fails, it can indeed mean, that
483 * this wasn't our capture interface, so, we wait for the right one 483 * this wasn't our capture interface, so, we wait for the right one
484 */ 484 */
485static int mt9m001_video_probe(struct soc_camera_link *icl, 485static int mt9m001_video_probe(struct soc_camera_subdev_desc *ssdd,
486 struct i2c_client *client) 486 struct i2c_client *client)
487{ 487{
488 struct mt9m001 *mt9m001 = to_mt9m001(client); 488 struct mt9m001 *mt9m001 = to_mt9m001(client);
@@ -526,8 +526,8 @@ static int mt9m001_video_probe(struct soc_camera_link *icl,
526 * The platform may support different bus widths due to 526 * The platform may support different bus widths due to
527 * different routing of the data lines. 527 * different routing of the data lines.
528 */ 528 */
529 if (icl->query_bus_param) 529 if (ssdd->query_bus_param)
530 flags = icl->query_bus_param(icl); 530 flags = ssdd->query_bus_param(ssdd);
531 else 531 else
532 flags = SOCAM_DATAWIDTH_10; 532 flags = SOCAM_DATAWIDTH_10;
533 533
@@ -558,10 +558,10 @@ done:
558 return ret; 558 return ret;
559} 559}
560 560
561static void mt9m001_video_remove(struct soc_camera_link *icl) 561static void mt9m001_video_remove(struct soc_camera_subdev_desc *ssdd)
562{ 562{
563 if (icl->free_bus) 563 if (ssdd->free_bus)
564 icl->free_bus(icl); 564 ssdd->free_bus(ssdd);
565} 565}
566 566
567static int mt9m001_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines) 567static int mt9m001_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines)
@@ -605,14 +605,14 @@ static int mt9m001_g_mbus_config(struct v4l2_subdev *sd,
605 struct v4l2_mbus_config *cfg) 605 struct v4l2_mbus_config *cfg)
606{ 606{
607 struct i2c_client *client = v4l2_get_subdevdata(sd); 607 struct i2c_client *client = v4l2_get_subdevdata(sd);
608 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 608 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
609 609
610 /* MT9M001 has all capture_format parameters fixed */ 610 /* MT9M001 has all capture_format parameters fixed */
611 cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING | 611 cfg->flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
612 V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH | 612 V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
613 V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER; 613 V4L2_MBUS_DATA_ACTIVE_HIGH | V4L2_MBUS_MASTER;
614 cfg->type = V4L2_MBUS_PARALLEL; 614 cfg->type = V4L2_MBUS_PARALLEL;
615 cfg->flags = soc_camera_apply_board_flags(icl, cfg); 615 cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
616 616
617 return 0; 617 return 0;
618} 618}
@@ -621,12 +621,12 @@ static int mt9m001_s_mbus_config(struct v4l2_subdev *sd,
621 const struct v4l2_mbus_config *cfg) 621 const struct v4l2_mbus_config *cfg)
622{ 622{
623 const struct i2c_client *client = v4l2_get_subdevdata(sd); 623 const struct i2c_client *client = v4l2_get_subdevdata(sd);
624 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 624 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
625 struct mt9m001 *mt9m001 = to_mt9m001(client); 625 struct mt9m001 *mt9m001 = to_mt9m001(client);
626 unsigned int bps = soc_mbus_get_fmtdesc(mt9m001->fmt->code)->bits_per_sample; 626 unsigned int bps = soc_mbus_get_fmtdesc(mt9m001->fmt->code)->bits_per_sample;
627 627
628 if (icl->set_bus_param) 628 if (ssdd->set_bus_param)
629 return icl->set_bus_param(icl, 1 << (bps - 1)); 629 return ssdd->set_bus_param(ssdd, 1 << (bps - 1));
630 630
631 /* 631 /*
632 * Without board specific bus width settings we only support the 632 * Without board specific bus width settings we only support the
@@ -663,10 +663,10 @@ static int mt9m001_probe(struct i2c_client *client,
663{ 663{
664 struct mt9m001 *mt9m001; 664 struct mt9m001 *mt9m001;
665 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); 665 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
666 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 666 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
667 int ret; 667 int ret;
668 668
669 if (!icl) { 669 if (!ssdd) {
670 dev_err(&client->dev, "MT9M001 driver needs platform data\n"); 670 dev_err(&client->dev, "MT9M001 driver needs platform data\n");
671 return -EINVAL; 671 return -EINVAL;
672 } 672 }
@@ -677,7 +677,7 @@ static int mt9m001_probe(struct i2c_client *client,
677 return -EIO; 677 return -EIO;
678 } 678 }
679 679
680 mt9m001 = kzalloc(sizeof(struct mt9m001), GFP_KERNEL); 680 mt9m001 = devm_kzalloc(&client->dev, sizeof(struct mt9m001), GFP_KERNEL);
681 if (!mt9m001) 681 if (!mt9m001)
682 return -ENOMEM; 682 return -ENOMEM;
683 683
@@ -697,12 +697,9 @@ static int mt9m001_probe(struct i2c_client *client,
697 &mt9m001_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, 697 &mt9m001_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0,
698 V4L2_EXPOSURE_AUTO); 698 V4L2_EXPOSURE_AUTO);
699 mt9m001->subdev.ctrl_handler = &mt9m001->hdl; 699 mt9m001->subdev.ctrl_handler = &mt9m001->hdl;
700 if (mt9m001->hdl.error) { 700 if (mt9m001->hdl.error)
701 int err = mt9m001->hdl.error; 701 return mt9m001->hdl.error;
702 702
703 kfree(mt9m001);
704 return err;
705 }
706 v4l2_ctrl_auto_cluster(2, &mt9m001->autoexposure, 703 v4l2_ctrl_auto_cluster(2, &mt9m001->autoexposure,
707 V4L2_EXPOSURE_MANUAL, true); 704 V4L2_EXPOSURE_MANUAL, true);
708 705
@@ -713,11 +710,9 @@ static int mt9m001_probe(struct i2c_client *client,
713 mt9m001->rect.width = MT9M001_MAX_WIDTH; 710 mt9m001->rect.width = MT9M001_MAX_WIDTH;
714 mt9m001->rect.height = MT9M001_MAX_HEIGHT; 711 mt9m001->rect.height = MT9M001_MAX_HEIGHT;
715 712
716 ret = mt9m001_video_probe(icl, client); 713 ret = mt9m001_video_probe(ssdd, client);
717 if (ret) { 714 if (ret)
718 v4l2_ctrl_handler_free(&mt9m001->hdl); 715 v4l2_ctrl_handler_free(&mt9m001->hdl);
719 kfree(mt9m001);
720 }
721 716
722 return ret; 717 return ret;
723} 718}
@@ -725,12 +720,11 @@ static int mt9m001_probe(struct i2c_client *client,
725static int mt9m001_remove(struct i2c_client *client) 720static int mt9m001_remove(struct i2c_client *client)
726{ 721{
727 struct mt9m001 *mt9m001 = to_mt9m001(client); 722 struct mt9m001 *mt9m001 = to_mt9m001(client);
728 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 723 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
729 724
730 v4l2_device_unregister_subdev(&mt9m001->subdev); 725 v4l2_device_unregister_subdev(&mt9m001->subdev);
731 v4l2_ctrl_handler_free(&mt9m001->hdl); 726 v4l2_ctrl_handler_free(&mt9m001->hdl);
732 mt9m001_video_remove(icl); 727 mt9m001_video_remove(ssdd);
733 kfree(mt9m001);
734 728
735 return 0; 729 return 0;
736} 730}