aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/smiapp
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2014-09-26 09:12:38 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-10-28 11:43:31 -0400
commite91cbeb29990d762c997ceec353a14fbbd80a0e1 (patch)
tree5c227a5e782b846f315f4a439a64039e432f0410 /drivers/media/i2c/smiapp
parentcd78b6afa7adb3aca9aa189ba5fb8a0adab647a2 (diff)
[media] smiapp: Clean up smiapp_set_format()
smiapp_set_format() has accumulated a fair amount of changes without a needed refactoring, do the cleanup now. There's also an unlocked version of v4l2_ctrl_range_changed(), using that fixes a small serialisation issue with the user space interface. __v4l2_ctrl_modify_range() is used instead of v4l2_ctrl_modify_range() in smiapp_set_format_source() since the mutex is now held during the function call. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/i2c/smiapp')
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c73
1 files changed, 43 insertions, 30 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 926f60c00ba1..416b7bd1142c 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -1728,51 +1728,64 @@ static const struct smiapp_csi_data_format
1728 return csi_format; 1728 return csi_format;
1729} 1729}
1730 1730
1731static int smiapp_set_format(struct v4l2_subdev *subdev, 1731static int smiapp_set_format_source(struct v4l2_subdev *subdev,
1732 struct v4l2_subdev_fh *fh, 1732 struct v4l2_subdev_fh *fh,
1733 struct v4l2_subdev_format *fmt) 1733 struct v4l2_subdev_format *fmt)
1734{ 1734{
1735 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 1735 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
1736 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev); 1736 const struct smiapp_csi_data_format *csi_format,
1737 struct v4l2_rect *crops[SMIAPP_PADS]; 1737 *old_csi_format = sensor->csi_format;
1738 u32 code = fmt->format.code;
1739 unsigned int i;
1740 int rval;
1738 1741
1739 mutex_lock(&sensor->mutex); 1742 rval = __smiapp_get_format(subdev, fh, fmt);
1743 if (rval)
1744 return rval;
1740 1745
1741 /* 1746 /*
1742 * Media bus code is changeable on src subdev's source pad. On 1747 * Media bus code is changeable on src subdev's source pad. On
1743 * other source pads we just get format here. 1748 * other source pads we just get format here.
1744 */ 1749 */
1745 if (fmt->pad == ssd->source_pad) { 1750 if (subdev != &sensor->src->sd)
1746 u32 code = fmt->format.code; 1751 return 0;
1747 int rval = __smiapp_get_format(subdev, fh, fmt);
1748 bool range_changed = false;
1749 unsigned int i;
1750
1751 if (!rval && subdev == &sensor->src->sd) {
1752 const struct smiapp_csi_data_format *csi_format =
1753 smiapp_validate_csi_data_format(sensor, code);
1754 1752
1755 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 1753 csi_format = smiapp_validate_csi_data_format(sensor, code);
1756 if (csi_format->width !=
1757 sensor->csi_format->width)
1758 range_changed = true;
1759 1754
1760 sensor->csi_format = csi_format; 1755 fmt->format.code = csi_format->code;
1761 }
1762 1756
1763 fmt->format.code = csi_format->code; 1757 if (fmt->which != V4L2_SUBDEV_FORMAT_ACTIVE)
1764 } 1758 return 0;
1765 1759
1766 mutex_unlock(&sensor->mutex); 1760 sensor->csi_format = csi_format;
1767 if (rval || !range_changed)
1768 return rval;
1769 1761
1762 if (csi_format->width != old_csi_format->width)
1770 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++) 1763 for (i = 0; i < ARRAY_SIZE(sensor->test_data); i++)
1771 v4l2_ctrl_modify_range( 1764 __v4l2_ctrl_modify_range(
1772 sensor->test_data[i], 1765 sensor->test_data[i], 0,
1773 0, (1 << sensor->csi_format->width) - 1, 1, 0); 1766 (1 << csi_format->width) - 1, 1, 0);
1774 1767
1775 return 0; 1768 return 0;
1769}
1770
1771static int smiapp_set_format(struct v4l2_subdev *subdev,
1772 struct v4l2_subdev_fh *fh,
1773 struct v4l2_subdev_format *fmt)
1774{
1775 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
1776 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
1777 struct v4l2_rect *crops[SMIAPP_PADS];
1778
1779 mutex_lock(&sensor->mutex);
1780
1781 if (fmt->pad == ssd->source_pad) {
1782 int rval;
1783
1784 rval = smiapp_set_format_source(subdev, fh, fmt);
1785
1786 mutex_unlock(&sensor->mutex);
1787
1788 return rval;
1776 } 1789 }
1777 1790
1778 /* Sink pad. Width and height are changeable here. */ 1791 /* Sink pad. Width and height are changeable here. */