aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/soc_camera
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-21 05:12:35 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-04-21 05:12:35 -0400
commit676ee36be04985062522804c2de04f0764212be6 (patch)
tree781df135c5a91a04decad1b7d53b5a925dc11522 /drivers/media/platform/soc_camera
parentb18042a673e88c9457a6d1716219c2367ca447b0 (diff)
parente183201b9e917daf2530b637b2f34f1d5afb934d (diff)
Merge branch 'patchwork' into v4l_for_linus
* patchwork: (404 commits) [media] uvcvideo: add support for VIDIOC_QUERY_EXT_CTRL [media] uvcvideo: fix cropcap v4l2-compliance failure [media] media: omap3isp: remove unused clkdev [media] coda: Add tracing support [media] coda: drop dma_sync_single_for_device in coda_bitstream_queue [media] coda: fix fill bitstream errors in nonstreaming case [media] coda: call SEQ_END when the first queue is stopped [media] coda: fail to start streaming if userspace set invalid formats [media] coda: remove duplicate error messages for buffer allocations [media] coda: move parameter buffer in together with context buffer allocation [media] coda: allocate bitstream buffer from REQBUFS, size depends on the format [media] coda: allocate per-context buffers from REQBUFS [media] coda: use strlcpy instead of snprintf [media] coda: bitstream payload is unsigned [media] coda: fix double call to debugfs_remove [media] coda: check kasprintf return value in coda_open [media] coda: bitrate can only be set in kbps steps [media] v4l2-mem2mem: no need to initialize b in v4l2_m2m_next_buf and v4l2_m2m_buf_remove [media] s5p-mfc: set allow_zero_bytesused flag for vb2_queue_init [media] coda: set allow_zero_bytesused flag for vb2_queue_init ...
Diffstat (limited to 'drivers/media/platform/soc_camera')
-rw-r--r--drivers/media/platform/soc_camera/rcar_vin.c15
-rw-r--r--drivers/media/platform/soc_camera/sh_mobile_csi2.c1
-rw-r--r--drivers/media/platform/soc_camera/soc_camera.c108
3 files changed, 64 insertions, 60 deletions
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 279ab9f6ae38..9351f64dee7b 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -977,19 +977,6 @@ static void rcar_vin_remove_device(struct soc_camera_device *icd)
977 icd->devnum); 977 icd->devnum);
978} 978}
979 979
980/* Called with .host_lock held */
981static int rcar_vin_clock_start(struct soc_camera_host *ici)
982{
983 /* VIN does not have "mclk" */
984 return 0;
985}
986
987/* Called with .host_lock held */
988static void rcar_vin_clock_stop(struct soc_camera_host *ici)
989{
990 /* VIN does not have "mclk" */
991}
992
993static void set_coeff(struct rcar_vin_priv *priv, unsigned short xs) 980static void set_coeff(struct rcar_vin_priv *priv, unsigned short xs)
994{ 981{
995 int i; 982 int i;
@@ -1803,8 +1790,6 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
1803 .owner = THIS_MODULE, 1790 .owner = THIS_MODULE,
1804 .add = rcar_vin_add_device, 1791 .add = rcar_vin_add_device,
1805 .remove = rcar_vin_remove_device, 1792 .remove = rcar_vin_remove_device,
1806 .clock_start = rcar_vin_clock_start,
1807 .clock_stop = rcar_vin_clock_stop,
1808 .get_formats = rcar_vin_get_formats, 1793 .get_formats = rcar_vin_get_formats,
1809 .put_formats = rcar_vin_put_formats, 1794 .put_formats = rcar_vin_put_formats,
1810 .get_crop = rcar_vin_get_crop, 1795 .get_crop = rcar_vin_get_crop,
diff --git a/drivers/media/platform/soc_camera/sh_mobile_csi2.c b/drivers/media/platform/soc_camera/sh_mobile_csi2.c
index c4e7aa0ee7e1..cd93241eb497 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_csi2.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_csi2.c
@@ -380,7 +380,6 @@ static int sh_csi2_remove(struct platform_device *pdev)
380 struct sh_csi2 *priv = container_of(subdev, struct sh_csi2, subdev); 380 struct sh_csi2 *priv = container_of(subdev, struct sh_csi2, subdev);
381 381
382 v4l2_async_unregister_subdev(&priv->subdev); 382 v4l2_async_unregister_subdev(&priv->subdev);
383 v4l2_device_unregister_subdev(subdev);
384 pm_runtime_disable(&pdev->dev); 383 pm_runtime_disable(&pdev->dev);
385 384
386 return 0; 385 return 0;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 66634b469c98..55370d74ff57 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -177,6 +177,30 @@ static int __soc_camera_power_off(struct soc_camera_device *icd)
177 return 0; 177 return 0;
178} 178}
179 179
180static int soc_camera_clock_start(struct soc_camera_host *ici)
181{
182 int ret;
183
184 if (!ici->ops->clock_start)
185 return 0;
186
187 mutex_lock(&ici->clk_lock);
188 ret = ici->ops->clock_start(ici);
189 mutex_unlock(&ici->clk_lock);
190
191 return ret;
192}
193
194static void soc_camera_clock_stop(struct soc_camera_host *ici)
195{
196 if (!ici->ops->clock_stop)
197 return;
198
199 mutex_lock(&ici->clk_lock);
200 ici->ops->clock_stop(ici);
201 mutex_unlock(&ici->clk_lock);
202}
203
180const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc( 204const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
181 struct soc_camera_device *icd, unsigned int fourcc) 205 struct soc_camera_device *icd, unsigned int fourcc)
182{ 206{
@@ -584,9 +608,7 @@ static int soc_camera_add_device(struct soc_camera_device *icd)
584 return -EBUSY; 608 return -EBUSY;
585 609
586 if (!icd->clk) { 610 if (!icd->clk) {
587 mutex_lock(&ici->clk_lock); 611 ret = soc_camera_clock_start(ici);
588 ret = ici->ops->clock_start(ici);
589 mutex_unlock(&ici->clk_lock);
590 if (ret < 0) 612 if (ret < 0)
591 return ret; 613 return ret;
592 } 614 }
@@ -602,11 +624,8 @@ static int soc_camera_add_device(struct soc_camera_device *icd)
602 return 0; 624 return 0;
603 625
604eadd: 626eadd:
605 if (!icd->clk) { 627 if (!icd->clk)
606 mutex_lock(&ici->clk_lock); 628 soc_camera_clock_stop(ici);
607 ici->ops->clock_stop(ici);
608 mutex_unlock(&ici->clk_lock);
609 }
610 return ret; 629 return ret;
611} 630}
612 631
@@ -619,11 +638,8 @@ static void soc_camera_remove_device(struct soc_camera_device *icd)
619 638
620 if (ici->ops->remove) 639 if (ici->ops->remove)
621 ici->ops->remove(icd); 640 ici->ops->remove(icd);
622 if (!icd->clk) { 641 if (!icd->clk)
623 mutex_lock(&ici->clk_lock); 642 soc_camera_clock_stop(ici);
624 ici->ops->clock_stop(ici);
625 mutex_unlock(&ici->clk_lock);
626 }
627 ici->icd = NULL; 643 ici->icd = NULL;
628} 644}
629 645
@@ -688,7 +704,8 @@ static int soc_camera_open(struct file *file)
688 704
689 /* The camera could have been already on, try to reset */ 705 /* The camera could have been already on, try to reset */
690 if (sdesc->subdev_desc.reset) 706 if (sdesc->subdev_desc.reset)
691 sdesc->subdev_desc.reset(icd->pdev); 707 if (icd->control)
708 sdesc->subdev_desc.reset(icd->control);
692 709
693 ret = soc_camera_add_device(icd); 710 ret = soc_camera_add_device(icd);
694 if (ret < 0) { 711 if (ret < 0) {
@@ -1159,7 +1176,8 @@ static void scan_add_host(struct soc_camera_host *ici)
1159 1176
1160 /* The camera could have been already on, try to reset */ 1177 /* The camera could have been already on, try to reset */
1161 if (ssdd->reset) 1178 if (ssdd->reset)
1162 ssdd->reset(icd->pdev); 1179 if (icd->control)
1180 ssdd->reset(icd->control);
1163 1181
1164 icd->parent = ici->v4l2_dev.dev; 1182 icd->parent = ici->v4l2_dev.dev;
1165 1183
@@ -1178,7 +1196,6 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk)
1178{ 1196{
1179 struct soc_camera_device *icd = clk->priv; 1197 struct soc_camera_device *icd = clk->priv;
1180 struct soc_camera_host *ici; 1198 struct soc_camera_host *ici;
1181 int ret;
1182 1199
1183 if (!icd || !icd->parent) 1200 if (!icd || !icd->parent)
1184 return -ENODEV; 1201 return -ENODEV;
@@ -1192,10 +1209,7 @@ static int soc_camera_clk_enable(struct v4l2_clk *clk)
1192 * If a different client is currently being probed, the host will tell 1209 * If a different client is currently being probed, the host will tell
1193 * you to go 1210 * you to go
1194 */ 1211 */
1195 mutex_lock(&ici->clk_lock); 1212 return soc_camera_clock_start(ici);
1196 ret = ici->ops->clock_start(ici);
1197 mutex_unlock(&ici->clk_lock);
1198 return ret;
1199} 1213}
1200 1214
1201static void soc_camera_clk_disable(struct v4l2_clk *clk) 1215static void soc_camera_clk_disable(struct v4l2_clk *clk)
@@ -1208,9 +1222,7 @@ static void soc_camera_clk_disable(struct v4l2_clk *clk)
1208 1222
1209 ici = to_soc_camera_host(icd->parent); 1223 ici = to_soc_camera_host(icd->parent);
1210 1224
1211 mutex_lock(&ici->clk_lock); 1225 soc_camera_clock_stop(ici);
1212 ici->ops->clock_stop(ici);
1213 mutex_unlock(&ici->clk_lock);
1214 1226
1215 module_put(ici->ops->owner); 1227 module_put(ici->ops->owner);
1216} 1228}
@@ -1364,7 +1376,7 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
1364 snprintf(clk_name, sizeof(clk_name), "%d-%04x", 1376 snprintf(clk_name, sizeof(clk_name), "%d-%04x",
1365 shd->i2c_adapter_id, shd->board_info->addr); 1377 shd->i2c_adapter_id, shd->board_info->addr);
1366 1378
1367 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd); 1379 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
1368 if (IS_ERR(icd->clk)) { 1380 if (IS_ERR(icd->clk)) {
1369 ret = PTR_ERR(icd->clk); 1381 ret = PTR_ERR(icd->clk);
1370 goto eclkreg; 1382 goto eclkreg;
@@ -1445,7 +1457,7 @@ static int soc_camera_async_bound(struct v4l2_async_notifier *notifier,
1445 memcpy(&sdesc->subdev_desc, ssdd, 1457 memcpy(&sdesc->subdev_desc, ssdd,
1446 sizeof(sdesc->subdev_desc)); 1458 sizeof(sdesc->subdev_desc));
1447 if (ssdd->reset) 1459 if (ssdd->reset)
1448 ssdd->reset(icd->pdev); 1460 ssdd->reset(&client->dev);
1449 } 1461 }
1450 1462
1451 icd->control = &client->dev; 1463 icd->control = &client->dev;
@@ -1545,7 +1557,7 @@ static int scan_async_group(struct soc_camera_host *ici,
1545 snprintf(clk_name, sizeof(clk_name), "%d-%04x", 1557 snprintf(clk_name, sizeof(clk_name), "%d-%04x",
1546 sasd->asd.match.i2c.adapter_id, sasd->asd.match.i2c.address); 1558 sasd->asd.match.i2c.adapter_id, sasd->asd.match.i2c.address);
1547 1559
1548 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd); 1560 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
1549 if (IS_ERR(icd->clk)) { 1561 if (IS_ERR(icd->clk)) {
1550 ret = PTR_ERR(icd->clk); 1562 ret = PTR_ERR(icd->clk);
1551 goto eclkreg; 1563 goto eclkreg;
@@ -1650,7 +1662,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
1650 snprintf(clk_name, sizeof(clk_name), "of-%s", 1662 snprintf(clk_name, sizeof(clk_name), "of-%s",
1651 of_node_full_name(remote)); 1663 of_node_full_name(remote));
1652 1664
1653 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd); 1665 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
1654 if (IS_ERR(icd->clk)) { 1666 if (IS_ERR(icd->clk)) {
1655 ret = PTR_ERR(icd->clk); 1667 ret = PTR_ERR(icd->clk);
1656 goto eclkreg; 1668 goto eclkreg;
@@ -1659,6 +1671,8 @@ static int soc_of_bind(struct soc_camera_host *ici,
1659 ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier); 1671 ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
1660 if (!ret) 1672 if (!ret)
1661 return 0; 1673 return 0;
1674
1675 v4l2_clk_unregister(icd->clk);
1662eclkreg: 1676eclkreg:
1663 icd->clk = NULL; 1677 icd->clk = NULL;
1664 platform_device_del(sasc->pdev); 1678 platform_device_del(sasc->pdev);
@@ -1750,9 +1764,7 @@ static int soc_camera_probe(struct soc_camera_host *ici,
1750 ret = -EINVAL; 1764 ret = -EINVAL;
1751 goto eadd; 1765 goto eadd;
1752 } else { 1766 } else {
1753 mutex_lock(&ici->clk_lock); 1767 ret = soc_camera_clock_start(ici);
1754 ret = ici->ops->clock_start(ici);
1755 mutex_unlock(&ici->clk_lock);
1756 if (ret < 0) 1768 if (ret < 0)
1757 goto eadd; 1769 goto eadd;
1758 1770
@@ -1792,9 +1804,7 @@ efinish:
1792 module_put(control->driver->owner); 1804 module_put(control->driver->owner);
1793enodrv: 1805enodrv:
1794eadddev: 1806eadddev:
1795 mutex_lock(&ici->clk_lock); 1807 soc_camera_clock_stop(ici);
1796 ici->ops->clock_stop(ici);
1797 mutex_unlock(&ici->clk_lock);
1798 } 1808 }
1799eadd: 1809eadd:
1800 if (icd->vdev) { 1810 if (icd->vdev) {
@@ -1888,22 +1898,34 @@ static int default_enum_framesizes(struct soc_camera_device *icd,
1888 int ret; 1898 int ret;
1889 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); 1899 struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
1890 const struct soc_camera_format_xlate *xlate; 1900 const struct soc_camera_format_xlate *xlate;
1891 __u32 pixfmt = fsize->pixel_format; 1901 struct v4l2_subdev_frame_size_enum fse = {
1892 struct v4l2_frmsizeenum fsize_mbus = *fsize; 1902 .index = fsize->index,
1903 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
1904 };
1893 1905
1894 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); 1906 xlate = soc_camera_xlate_by_fourcc(icd, fsize->pixel_format);
1895 if (!xlate) 1907 if (!xlate)
1896 return -EINVAL; 1908 return -EINVAL;
1897 /* map xlate-code to pixel_format, sensor only handle xlate-code*/ 1909 fse.code = xlate->code;
1898 fsize_mbus.pixel_format = xlate->code;
1899 1910
1900 ret = v4l2_subdev_call(sd, video, enum_framesizes, &fsize_mbus); 1911 ret = v4l2_subdev_call(sd, pad, enum_frame_size, NULL, &fse);
1901 if (ret < 0) 1912 if (ret < 0)
1902 return ret; 1913 return ret;
1903 1914
1904 *fsize = fsize_mbus; 1915 if (fse.min_width == fse.max_width &&
1905 fsize->pixel_format = pixfmt; 1916 fse.min_height == fse.max_height) {
1906 1917 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1918 fsize->discrete.width = fse.min_width;
1919 fsize->discrete.height = fse.min_height;
1920 return 0;
1921 }
1922 fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
1923 fsize->stepwise.min_width = fse.min_width;
1924 fsize->stepwise.max_width = fse.max_width;
1925 fsize->stepwise.min_height = fse.min_height;
1926 fsize->stepwise.max_height = fse.max_height;
1927 fsize->stepwise.step_width = 1;
1928 fsize->stepwise.step_height = 1;
1907 return 0; 1929 return 0;
1908} 1930}
1909 1931
@@ -1920,8 +1942,6 @@ int soc_camera_host_register(struct soc_camera_host *ici)
1920 ((!ici->ops->init_videobuf || 1942 ((!ici->ops->init_videobuf ||
1921 !ici->ops->reqbufs) && 1943 !ici->ops->reqbufs) &&
1922 !ici->ops->init_videobuf2) || 1944 !ici->ops->init_videobuf2) ||
1923 !ici->ops->clock_start ||
1924 !ici->ops->clock_stop ||
1925 !ici->ops->poll || 1945 !ici->ops->poll ||
1926 !ici->v4l2_dev.dev) 1946 !ici->v4l2_dev.dev)
1927 return -EINVAL; 1947 return -EINVAL;