diff options
| author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-04-16 08:41:25 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-17 08:18:09 -0400 |
| commit | 0ba2aeb6dab80920edd9cf5b93b1ea4d6913b8f3 (patch) | |
| tree | dd9f045fa482ee601cdf4ee67c649530f22abc5e | |
| parent | 7d6bc608e062f6b6667c9eeeb17055f017ecadb1 (diff) | |
[media] v4l2-ctrls: increase internal min/max/step/def to 64 bit
While VIDIOC_QUERYCTRL is limited to 32 bit min/max/step/def values
for controls, the upcoming VIDIOC_QUERY_EXT_CTRL isn't. So increase
the internal representation to 64 bits in preparation.
Because of these changes the msi3101 driver has been modified slightly
to fix a formatting issue (%d becomes %lld), vivi had to be modified
as well to cope with the new 64-bit min/max values and the PIXEL_RATE
control in a few sensor drivers required proper min/max/def values.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
| -rw-r--r-- | drivers/media/i2c/mt9v032.c | 2 | ||||
| -rw-r--r-- | drivers/media/i2c/smiapp/smiapp-core.c | 4 | ||||
| -rw-r--r-- | drivers/media/platform/vivi.c | 5 | ||||
| -rw-r--r-- | drivers/media/v4l2-core/v4l2-common.c | 6 | ||||
| -rw-r--r-- | drivers/media/v4l2-core/v4l2-ctrls.c | 93 | ||||
| -rw-r--r-- | drivers/staging/media/msi3101/msi001.c | 2 | ||||
| -rw-r--r-- | drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 6 | ||||
| -rw-r--r-- | include/media/v4l2-ctrls.h | 42 |
8 files changed, 94 insertions, 66 deletions
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index 40172b8d8ea2..65e6e1a9d104 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c | |||
| @@ -931,7 +931,7 @@ static int mt9v032_probe(struct i2c_client *client, | |||
| 931 | 931 | ||
| 932 | mt9v032->pixel_rate = | 932 | mt9v032->pixel_rate = |
| 933 | v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops, | 933 | v4l2_ctrl_new_std(&mt9v032->ctrls, &mt9v032_ctrl_ops, |
| 934 | V4L2_CID_PIXEL_RATE, 0, 0, 1, 0); | 934 | V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); |
| 935 | 935 | ||
| 936 | if (pdata && pdata->link_freqs) { | 936 | if (pdata && pdata->link_freqs) { |
| 937 | unsigned int def = 0; | 937 | unsigned int def = 0; |
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 446c82c58a62..72350f0befc5 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c | |||
| @@ -533,7 +533,7 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor) | |||
| 533 | 533 | ||
| 534 | sensor->pixel_rate_parray = v4l2_ctrl_new_std( | 534 | sensor->pixel_rate_parray = v4l2_ctrl_new_std( |
| 535 | &sensor->pixel_array->ctrl_handler, &smiapp_ctrl_ops, | 535 | &sensor->pixel_array->ctrl_handler, &smiapp_ctrl_ops, |
| 536 | V4L2_CID_PIXEL_RATE, 0, 0, 1, 0); | 536 | V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); |
| 537 | 537 | ||
| 538 | if (sensor->pixel_array->ctrl_handler.error) { | 538 | if (sensor->pixel_array->ctrl_handler.error) { |
| 539 | dev_err(&client->dev, | 539 | dev_err(&client->dev, |
| @@ -562,7 +562,7 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor) | |||
| 562 | 562 | ||
| 563 | sensor->pixel_rate_csi = v4l2_ctrl_new_std( | 563 | sensor->pixel_rate_csi = v4l2_ctrl_new_std( |
| 564 | &sensor->src->ctrl_handler, &smiapp_ctrl_ops, | 564 | &sensor->src->ctrl_handler, &smiapp_ctrl_ops, |
| 565 | V4L2_CID_PIXEL_RATE, 0, 0, 1, 0); | 565 | V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); |
| 566 | 566 | ||
| 567 | if (sensor->src->ctrl_handler.error) { | 567 | if (sensor->src->ctrl_handler.error) { |
| 568 | dev_err(&client->dev, | 568 | dev_err(&client->dev, |
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c index b7fbcdfc5862..cd535b38469d 100644 --- a/drivers/media/platform/vivi.c +++ b/drivers/media/platform/vivi.c | |||
| @@ -1236,7 +1236,7 @@ static const struct v4l2_ctrl_config vivi_ctrl_int32 = { | |||
| 1236 | .id = VIVI_CID_CUSTOM_BASE + 2, | 1236 | .id = VIVI_CID_CUSTOM_BASE + 2, |
| 1237 | .name = "Integer 32 Bits", | 1237 | .name = "Integer 32 Bits", |
| 1238 | .type = V4L2_CTRL_TYPE_INTEGER, | 1238 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 1239 | .min = 0x80000000, | 1239 | .min = -0x80000000LL, |
| 1240 | .max = 0x7fffffff, | 1240 | .max = 0x7fffffff, |
| 1241 | .step = 1, | 1241 | .step = 1, |
| 1242 | }; | 1242 | }; |
| @@ -1246,6 +1246,9 @@ static const struct v4l2_ctrl_config vivi_ctrl_int64 = { | |||
| 1246 | .id = VIVI_CID_CUSTOM_BASE + 3, | 1246 | .id = VIVI_CID_CUSTOM_BASE + 3, |
| 1247 | .name = "Integer 64 Bits", | 1247 | .name = "Integer 64 Bits", |
| 1248 | .type = V4L2_CTRL_TYPE_INTEGER64, | 1248 | .type = V4L2_CTRL_TYPE_INTEGER64, |
| 1249 | .min = LLONG_MIN, | ||
| 1250 | .max = LLONG_MAX, | ||
| 1251 | .step = 1, | ||
| 1249 | }; | 1252 | }; |
| 1250 | 1253 | ||
| 1251 | static const char * const vivi_ctrl_menu_strings[] = { | 1254 | static const char * const vivi_ctrl_menu_strings[] = { |
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 433d6d77942e..ccaa38f65cf1 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c | |||
| @@ -111,9 +111,13 @@ int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, | |||
| 111 | EXPORT_SYMBOL(v4l2_ctrl_check); | 111 | EXPORT_SYMBOL(v4l2_ctrl_check); |
| 112 | 112 | ||
| 113 | /* Fill in a struct v4l2_queryctrl */ | 113 | /* Fill in a struct v4l2_queryctrl */ |
| 114 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) | 114 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 _min, s32 _max, s32 _step, s32 _def) |
| 115 | { | 115 | { |
| 116 | const char *name; | 116 | const char *name; |
| 117 | s64 min = _min; | ||
| 118 | s64 max = _max; | ||
| 119 | u64 step = _step; | ||
| 120 | s64 def = _def; | ||
| 117 | 121 | ||
| 118 | v4l2_ctrl_fill(qctrl->id, &name, &qctrl->type, | 122 | v4l2_ctrl_fill(qctrl->id, &name, &qctrl->type, |
| 119 | &min, &max, &step, &def, &qctrl->flags); | 123 | &min, &max, &step, &def, &qctrl->flags); |
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 55c683254102..e132fa21ccd6 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c | |||
| @@ -877,7 +877,7 @@ const char *v4l2_ctrl_get_name(u32 id) | |||
| 877 | EXPORT_SYMBOL(v4l2_ctrl_get_name); | 877 | EXPORT_SYMBOL(v4l2_ctrl_get_name); |
| 878 | 878 | ||
| 879 | void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, | 879 | void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, |
| 880 | s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags) | 880 | s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags) |
| 881 | { | 881 | { |
| 882 | *name = v4l2_ctrl_get_name(id); | 882 | *name = v4l2_ctrl_get_name(id); |
| 883 | *flags = 0; | 883 | *flags = 0; |
| @@ -1041,14 +1041,23 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, | |||
| 1041 | *type = V4L2_CTRL_TYPE_INTEGER; | 1041 | *type = V4L2_CTRL_TYPE_INTEGER; |
| 1042 | *flags |= V4L2_CTRL_FLAG_READ_ONLY; | 1042 | *flags |= V4L2_CTRL_FLAG_READ_ONLY; |
| 1043 | break; | 1043 | break; |
| 1044 | case V4L2_CID_MPEG_VIDEO_DEC_FRAME: | ||
| 1045 | case V4L2_CID_MPEG_VIDEO_DEC_PTS: | 1044 | case V4L2_CID_MPEG_VIDEO_DEC_PTS: |
| 1046 | *flags |= V4L2_CTRL_FLAG_VOLATILE; | 1045 | *type = V4L2_CTRL_TYPE_INTEGER64; |
| 1047 | /* Fall through */ | 1046 | *flags |= V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY; |
| 1047 | *min = *def = 0; | ||
| 1048 | *max = 0x1ffffffffLL; | ||
| 1049 | *step = 1; | ||
| 1050 | break; | ||
| 1051 | case V4L2_CID_MPEG_VIDEO_DEC_FRAME: | ||
| 1052 | *type = V4L2_CTRL_TYPE_INTEGER64; | ||
| 1053 | *flags |= V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY; | ||
| 1054 | *min = *def = 0; | ||
| 1055 | *max = 0x7fffffffffffffffLL; | ||
| 1056 | *step = 1; | ||
| 1057 | break; | ||
| 1048 | case V4L2_CID_PIXEL_RATE: | 1058 | case V4L2_CID_PIXEL_RATE: |
| 1049 | *type = V4L2_CTRL_TYPE_INTEGER64; | 1059 | *type = V4L2_CTRL_TYPE_INTEGER64; |
| 1050 | *flags |= V4L2_CTRL_FLAG_READ_ONLY; | 1060 | *flags |= V4L2_CTRL_FLAG_READ_ONLY; |
| 1051 | *min = *max = *step = *def = 0; | ||
| 1052 | break; | 1061 | break; |
| 1053 | default: | 1062 | default: |
| 1054 | *type = V4L2_CTRL_TYPE_INTEGER; | 1063 | *type = V4L2_CTRL_TYPE_INTEGER; |
| @@ -1352,7 +1361,7 @@ static int cluster_changed(struct v4l2_ctrl *master) | |||
| 1352 | 1361 | ||
| 1353 | /* Control range checking */ | 1362 | /* Control range checking */ |
| 1354 | static int check_range(enum v4l2_ctrl_type type, | 1363 | static int check_range(enum v4l2_ctrl_type type, |
| 1355 | s32 min, s32 max, u32 step, s32 def) | 1364 | s64 min, s64 max, u64 step, s64 def) |
| 1356 | { | 1365 | { |
| 1357 | switch (type) { | 1366 | switch (type) { |
| 1358 | case V4L2_CTRL_TYPE_BOOLEAN: | 1367 | case V4L2_CTRL_TYPE_BOOLEAN: |
| @@ -1360,7 +1369,8 @@ static int check_range(enum v4l2_ctrl_type type, | |||
| 1360 | return -ERANGE; | 1369 | return -ERANGE; |
| 1361 | /* fall through */ | 1370 | /* fall through */ |
| 1362 | case V4L2_CTRL_TYPE_INTEGER: | 1371 | case V4L2_CTRL_TYPE_INTEGER: |
| 1363 | if (step <= 0 || min > max || def < min || def > max) | 1372 | case V4L2_CTRL_TYPE_INTEGER64: |
| 1373 | if (step == 0 || min > max || def < min || def > max) | ||
| 1364 | return -ERANGE; | 1374 | return -ERANGE; |
| 1365 | return 0; | 1375 | return 0; |
| 1366 | case V4L2_CTRL_TYPE_BITMASK: | 1376 | case V4L2_CTRL_TYPE_BITMASK: |
| @@ -1385,23 +1395,30 @@ static int check_range(enum v4l2_ctrl_type type, | |||
| 1385 | } | 1395 | } |
| 1386 | } | 1396 | } |
| 1387 | 1397 | ||
| 1398 | /* Round towards the closest legal value */ | ||
| 1399 | #define ROUND_TO_RANGE(val, offset_type, ctrl) \ | ||
| 1400 | ({ \ | ||
| 1401 | offset_type offset; \ | ||
| 1402 | val += (ctrl)->step / 2; \ | ||
| 1403 | val = clamp_t(typeof(val), val, \ | ||
| 1404 | (ctrl)->minimum, (ctrl)->maximum); \ | ||
| 1405 | offset = (val) - (ctrl)->minimum; \ | ||
| 1406 | offset = (ctrl)->step * (offset / (ctrl)->step); \ | ||
| 1407 | val = (ctrl)->minimum + offset; \ | ||
| 1408 | 0; \ | ||
| 1409 | }) | ||
| 1410 | |||
| 1388 | /* Validate a new control */ | 1411 | /* Validate a new control */ |
| 1389 | static int validate_new(const struct v4l2_ctrl *ctrl, | 1412 | static int validate_new(const struct v4l2_ctrl *ctrl, |
| 1390 | struct v4l2_ext_control *c) | 1413 | struct v4l2_ext_control *c) |
| 1391 | { | 1414 | { |
| 1392 | size_t len; | 1415 | size_t len; |
| 1393 | u32 offset; | ||
| 1394 | s32 val; | ||
| 1395 | 1416 | ||
| 1396 | switch (ctrl->type) { | 1417 | switch (ctrl->type) { |
| 1397 | case V4L2_CTRL_TYPE_INTEGER: | 1418 | case V4L2_CTRL_TYPE_INTEGER: |
| 1398 | /* Round towards the closest legal value */ | 1419 | return ROUND_TO_RANGE(*(s32 *)&c->value, u32, ctrl); |
| 1399 | val = c->value + ctrl->step / 2; | 1420 | case V4L2_CTRL_TYPE_INTEGER64: |
| 1400 | val = clamp(val, ctrl->minimum, ctrl->maximum); | 1421 | return ROUND_TO_RANGE(*(s64 *)&c->value64, u64, ctrl); |
| 1401 | offset = val - ctrl->minimum; | ||
| 1402 | offset = ctrl->step * (offset / ctrl->step); | ||
| 1403 | c->value = ctrl->minimum + offset; | ||
| 1404 | return 0; | ||
| 1405 | 1422 | ||
| 1406 | case V4L2_CTRL_TYPE_BOOLEAN: | 1423 | case V4L2_CTRL_TYPE_BOOLEAN: |
| 1407 | c->value = !!c->value; | 1424 | c->value = !!c->value; |
| @@ -1427,9 +1444,6 @@ static int validate_new(const struct v4l2_ctrl *ctrl, | |||
| 1427 | c->value = 0; | 1444 | c->value = 0; |
| 1428 | return 0; | 1445 | return 0; |
| 1429 | 1446 | ||
| 1430 | case V4L2_CTRL_TYPE_INTEGER64: | ||
| 1431 | return 0; | ||
| 1432 | |||
| 1433 | case V4L2_CTRL_TYPE_STRING: | 1447 | case V4L2_CTRL_TYPE_STRING: |
| 1434 | len = strlen(c->string); | 1448 | len = strlen(c->string); |
| 1435 | if (len < ctrl->minimum) | 1449 | if (len < ctrl->minimum) |
| @@ -1653,7 +1667,7 @@ unlock: | |||
| 1653 | static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, | 1667 | static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, |
| 1654 | const struct v4l2_ctrl_ops *ops, | 1668 | const struct v4l2_ctrl_ops *ops, |
| 1655 | u32 id, const char *name, enum v4l2_ctrl_type type, | 1669 | u32 id, const char *name, enum v4l2_ctrl_type type, |
| 1656 | s32 min, s32 max, u32 step, s32 def, | 1670 | s64 min, s64 max, u64 step, s64 def, |
| 1657 | u32 flags, const char * const *qmenu, | 1671 | u32 flags, const char * const *qmenu, |
| 1658 | const s64 *qmenu_int, void *priv) | 1672 | const s64 *qmenu_int, void *priv) |
| 1659 | { | 1673 | { |
| @@ -1738,10 +1752,10 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, | |||
| 1738 | const s64 *qmenu_int = cfg->qmenu_int; | 1752 | const s64 *qmenu_int = cfg->qmenu_int; |
| 1739 | enum v4l2_ctrl_type type = cfg->type; | 1753 | enum v4l2_ctrl_type type = cfg->type; |
| 1740 | u32 flags = cfg->flags; | 1754 | u32 flags = cfg->flags; |
| 1741 | s32 min = cfg->min; | 1755 | s64 min = cfg->min; |
| 1742 | s32 max = cfg->max; | 1756 | s64 max = cfg->max; |
| 1743 | u32 step = cfg->step; | 1757 | u64 step = cfg->step; |
| 1744 | s32 def = cfg->def; | 1758 | s64 def = cfg->def; |
| 1745 | 1759 | ||
| 1746 | if (name == NULL) | 1760 | if (name == NULL) |
| 1747 | v4l2_ctrl_fill(cfg->id, &name, &type, &min, &max, &step, | 1761 | v4l2_ctrl_fill(cfg->id, &name, &type, &min, &max, &step, |
| @@ -1774,7 +1788,7 @@ EXPORT_SYMBOL(v4l2_ctrl_new_custom); | |||
| 1774 | /* Helper function for standard non-menu controls */ | 1788 | /* Helper function for standard non-menu controls */ |
| 1775 | struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, | 1789 | struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, |
| 1776 | const struct v4l2_ctrl_ops *ops, | 1790 | const struct v4l2_ctrl_ops *ops, |
| 1777 | u32 id, s32 min, s32 max, u32 step, s32 def) | 1791 | u32 id, s64 min, s64 max, u64 step, s64 def) |
| 1778 | { | 1792 | { |
| 1779 | const char *name; | 1793 | const char *name; |
| 1780 | enum v4l2_ctrl_type type; | 1794 | enum v4l2_ctrl_type type; |
| @@ -1794,15 +1808,17 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std); | |||
| 1794 | /* Helper function for standard menu controls */ | 1808 | /* Helper function for standard menu controls */ |
| 1795 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | 1809 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, |
| 1796 | const struct v4l2_ctrl_ops *ops, | 1810 | const struct v4l2_ctrl_ops *ops, |
| 1797 | u32 id, s32 max, s32 mask, s32 def) | 1811 | u32 id, u8 _max, u64 mask, u8 _def) |
| 1798 | { | 1812 | { |
| 1799 | const char * const *qmenu = NULL; | 1813 | const char * const *qmenu = NULL; |
| 1800 | const s64 *qmenu_int = NULL; | 1814 | const s64 *qmenu_int = NULL; |
| 1801 | unsigned int qmenu_int_len = 0; | 1815 | unsigned int qmenu_int_len = 0; |
| 1802 | const char *name; | 1816 | const char *name; |
| 1803 | enum v4l2_ctrl_type type; | 1817 | enum v4l2_ctrl_type type; |
| 1804 | s32 min; | 1818 | s64 min; |
| 1805 | s32 step; | 1819 | s64 max = _max; |
| 1820 | s64 def = _def; | ||
| 1821 | u64 step; | ||
| 1806 | u32 flags; | 1822 | u32 flags; |
| 1807 | 1823 | ||
| 1808 | v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags); | 1824 | v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags); |
| @@ -1823,14 +1839,16 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); | |||
| 1823 | 1839 | ||
| 1824 | /* Helper function for standard menu controls with driver defined menu */ | 1840 | /* Helper function for standard menu controls with driver defined menu */ |
| 1825 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, | 1841 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, |
| 1826 | const struct v4l2_ctrl_ops *ops, u32 id, s32 max, | 1842 | const struct v4l2_ctrl_ops *ops, u32 id, u8 _max, |
| 1827 | s32 mask, s32 def, const char * const *qmenu) | 1843 | u64 mask, u8 _def, const char * const *qmenu) |
| 1828 | { | 1844 | { |
| 1829 | enum v4l2_ctrl_type type; | 1845 | enum v4l2_ctrl_type type; |
| 1830 | const char *name; | 1846 | const char *name; |
| 1831 | u32 flags; | 1847 | u32 flags; |
| 1832 | s32 step; | 1848 | u64 step; |
| 1833 | s32 min; | 1849 | s64 min; |
| 1850 | s64 max = _max; | ||
| 1851 | s64 def = _def; | ||
| 1834 | 1852 | ||
| 1835 | /* v4l2_ctrl_new_std_menu_items() should only be called for | 1853 | /* v4l2_ctrl_new_std_menu_items() should only be called for |
| 1836 | * standard controls without a standard menu. | 1854 | * standard controls without a standard menu. |
| @@ -1854,12 +1872,14 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); | |||
| 1854 | /* Helper function for standard integer menu controls */ | 1872 | /* Helper function for standard integer menu controls */ |
| 1855 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, | 1873 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, |
| 1856 | const struct v4l2_ctrl_ops *ops, | 1874 | const struct v4l2_ctrl_ops *ops, |
| 1857 | u32 id, s32 max, s32 def, const s64 *qmenu_int) | 1875 | u32 id, u8 _max, u8 _def, const s64 *qmenu_int) |
| 1858 | { | 1876 | { |
| 1859 | const char *name; | 1877 | const char *name; |
| 1860 | enum v4l2_ctrl_type type; | 1878 | enum v4l2_ctrl_type type; |
| 1861 | s32 min; | 1879 | s64 min; |
| 1862 | s32 step; | 1880 | u64 step; |
| 1881 | s64 max = _max; | ||
| 1882 | s64 def = _def; | ||
| 1863 | u32 flags; | 1883 | u32 flags; |
| 1864 | 1884 | ||
| 1865 | v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags); | 1885 | v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags); |
| @@ -2887,13 +2907,14 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void | |||
| 2887 | EXPORT_SYMBOL(v4l2_ctrl_notify); | 2907 | EXPORT_SYMBOL(v4l2_ctrl_notify); |
| 2888 | 2908 | ||
| 2889 | int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, | 2909 | int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, |
| 2890 | s32 min, s32 max, u32 step, s32 def) | 2910 | s64 min, s64 max, u64 step, s64 def) |
| 2891 | { | 2911 | { |
| 2892 | int ret = check_range(ctrl->type, min, max, step, def); | 2912 | int ret = check_range(ctrl->type, min, max, step, def); |
| 2893 | struct v4l2_ext_control c; | 2913 | struct v4l2_ext_control c; |
| 2894 | 2914 | ||
| 2895 | switch (ctrl->type) { | 2915 | switch (ctrl->type) { |
| 2896 | case V4L2_CTRL_TYPE_INTEGER: | 2916 | case V4L2_CTRL_TYPE_INTEGER: |
| 2917 | case V4L2_CTRL_TYPE_INTEGER64: | ||
| 2897 | case V4L2_CTRL_TYPE_BOOLEAN: | 2918 | case V4L2_CTRL_TYPE_BOOLEAN: |
| 2898 | case V4L2_CTRL_TYPE_MENU: | 2919 | case V4L2_CTRL_TYPE_MENU: |
| 2899 | case V4L2_CTRL_TYPE_INTEGER_MENU: | 2920 | case V4L2_CTRL_TYPE_INTEGER_MENU: |
diff --git a/drivers/staging/media/msi3101/msi001.c b/drivers/staging/media/msi3101/msi001.c index bd0b93cb6c53..ee99e372c943 100644 --- a/drivers/staging/media/msi3101/msi001.c +++ b/drivers/staging/media/msi3101/msi001.c | |||
| @@ -381,7 +381,7 @@ static int msi001_s_ctrl(struct v4l2_ctrl *ctrl) | |||
| 381 | 381 | ||
| 382 | int ret; | 382 | int ret; |
| 383 | dev_dbg(&s->spi->dev, | 383 | dev_dbg(&s->spi->dev, |
| 384 | "%s: id=%d name=%s val=%d min=%d max=%d step=%d\n", | 384 | "%s: id=%d name=%s val=%d min=%lld max=%lld step=%lld\n", |
| 385 | __func__, ctrl->id, ctrl->name, ctrl->val, | 385 | __func__, ctrl->id, ctrl->name, ctrl->val, |
| 386 | ctrl->minimum, ctrl->maximum, ctrl->step); | 386 | ctrl->minimum, ctrl->maximum, ctrl->step); |
| 387 | 387 | ||
diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c index cee127362b0b..f81b1c84dae1 100644 --- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c +++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | |||
| @@ -1337,7 +1337,7 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl) | |||
| 1337 | int ret; | 1337 | int ret; |
| 1338 | 1338 | ||
| 1339 | dev_dbg(&s->udev->dev, | 1339 | dev_dbg(&s->udev->dev, |
| 1340 | "%s: id=%d name=%s val=%d min=%d max=%d step=%d\n", | 1340 | "%s: id=%d name=%s val=%d min=%lld max=%lld step=%lld\n", |
| 1341 | __func__, ctrl->id, ctrl->name, ctrl->val, | 1341 | __func__, ctrl->id, ctrl->name, ctrl->val, |
| 1342 | ctrl->minimum, ctrl->maximum, ctrl->step); | 1342 | ctrl->minimum, ctrl->maximum, ctrl->step); |
| 1343 | 1343 | ||
| @@ -1350,8 +1350,8 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl) | |||
| 1350 | s32 val = s->f_adc + s->bandwidth->step / 2; | 1350 | s32 val = s->f_adc + s->bandwidth->step / 2; |
| 1351 | u32 offset; | 1351 | u32 offset; |
| 1352 | 1352 | ||
| 1353 | val = clamp(val, s->bandwidth->minimum, | 1353 | val = clamp_t(s32, val, s->bandwidth->minimum, |
| 1354 | s->bandwidth->maximum); | 1354 | s->bandwidth->maximum); |
| 1355 | offset = val - s->bandwidth->minimum; | 1355 | offset = val - s->bandwidth->minimum; |
| 1356 | offset = s->bandwidth->step * | 1356 | offset = s->bandwidth->step * |
| 1357 | (offset / s->bandwidth->step); | 1357 | (offset / s->bandwidth->step); |
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 16f7f2606516..a2e8f038a8ed 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h | |||
| @@ -131,10 +131,10 @@ struct v4l2_ctrl { | |||
| 131 | u32 id; | 131 | u32 id; |
| 132 | const char *name; | 132 | const char *name; |
| 133 | enum v4l2_ctrl_type type; | 133 | enum v4l2_ctrl_type type; |
| 134 | s32 minimum, maximum, default_value; | 134 | s64 minimum, maximum, default_value; |
| 135 | union { | 135 | union { |
| 136 | u32 step; | 136 | u64 step; |
| 137 | u32 menu_skip_mask; | 137 | u64 menu_skip_mask; |
| 138 | }; | 138 | }; |
| 139 | union { | 139 | union { |
| 140 | const char * const *qmenu; | 140 | const char * const *qmenu; |
| @@ -216,9 +216,9 @@ struct v4l2_ctrl_handler { | |||
| 216 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it | 216 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it |
| 217 | * easy to skip menu items that are not valid. If bit X is set, | 217 | * easy to skip menu items that are not valid. If bit X is set, |
| 218 | * then menu item X is skipped. Of course, this only works for | 218 | * then menu item X is skipped. Of course, this only works for |
| 219 | * menus with <= 32 menu items. There are no menus that come | 219 | * menus with <= 64 menu items. There are no menus that come |
| 220 | * close to that number, so this is OK. Should we ever need more, | 220 | * close to that number, so this is OK. Should we ever need more, |
| 221 | * then this will have to be extended to a u64 or a bit array. | 221 | * then this will have to be extended to a bit array. |
| 222 | * @qmenu: A const char * array for all menu items. Array entries that are | 222 | * @qmenu: A const char * array for all menu items. Array entries that are |
| 223 | * empty strings ("") correspond to non-existing menu items (this | 223 | * empty strings ("") correspond to non-existing menu items (this |
| 224 | * is in addition to the menu_skip_mask above). The last entry | 224 | * is in addition to the menu_skip_mask above). The last entry |
| @@ -231,12 +231,12 @@ struct v4l2_ctrl_config { | |||
| 231 | u32 id; | 231 | u32 id; |
| 232 | const char *name; | 232 | const char *name; |
| 233 | enum v4l2_ctrl_type type; | 233 | enum v4l2_ctrl_type type; |
| 234 | s32 min; | 234 | s64 min; |
| 235 | s32 max; | 235 | s64 max; |
| 236 | u32 step; | 236 | u64 step; |
| 237 | s32 def; | 237 | s64 def; |
| 238 | u32 flags; | 238 | u32 flags; |
| 239 | u32 menu_skip_mask; | 239 | u64 menu_skip_mask; |
| 240 | const char * const *qmenu; | 240 | const char * const *qmenu; |
| 241 | const s64 *qmenu_int; | 241 | const s64 *qmenu_int; |
| 242 | unsigned int is_private:1; | 242 | unsigned int is_private:1; |
| @@ -257,7 +257,7 @@ struct v4l2_ctrl_config { | |||
| 257 | * control framework this function will no longer be exported. | 257 | * control framework this function will no longer be exported. |
| 258 | */ | 258 | */ |
| 259 | void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, | 259 | void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, |
| 260 | s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags); | 260 | s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags); |
| 261 | 261 | ||
| 262 | 262 | ||
| 263 | /** v4l2_ctrl_handler_init_class() - Initialize the control handler. | 263 | /** v4l2_ctrl_handler_init_class() - Initialize the control handler. |
| @@ -362,7 +362,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, | |||
| 362 | */ | 362 | */ |
| 363 | struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, | 363 | struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, |
| 364 | const struct v4l2_ctrl_ops *ops, | 364 | const struct v4l2_ctrl_ops *ops, |
| 365 | u32 id, s32 min, s32 max, u32 step, s32 def); | 365 | u32 id, s64 min, s64 max, u64 step, s64 def); |
| 366 | 366 | ||
| 367 | /** v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 menu control. | 367 | /** v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 menu control. |
| 368 | * @hdl: The control handler. | 368 | * @hdl: The control handler. |
| @@ -372,9 +372,9 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, | |||
| 372 | * @mask: The control's skip mask for menu controls. This makes it | 372 | * @mask: The control's skip mask for menu controls. This makes it |
| 373 | * easy to skip menu items that are not valid. If bit X is set, | 373 | * easy to skip menu items that are not valid. If bit X is set, |
| 374 | * then menu item X is skipped. Of course, this only works for | 374 | * then menu item X is skipped. Of course, this only works for |
| 375 | * menus with <= 32 menu items. There are no menus that come | 375 | * menus with <= 64 menu items. There are no menus that come |
| 376 | * close to that number, so this is OK. Should we ever need more, | 376 | * close to that number, so this is OK. Should we ever need more, |
| 377 | * then this will have to be extended to a u64 or a bit array. | 377 | * then this will have to be extended to a bit array. |
| 378 | * @def: The control's default value. | 378 | * @def: The control's default value. |
| 379 | * | 379 | * |
| 380 | * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value | 380 | * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value |
| @@ -384,7 +384,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, | |||
| 384 | */ | 384 | */ |
| 385 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | 385 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, |
| 386 | const struct v4l2_ctrl_ops *ops, | 386 | const struct v4l2_ctrl_ops *ops, |
| 387 | u32 id, s32 max, s32 mask, s32 def); | 387 | u32 id, u8 max, u64 mask, u8 def); |
| 388 | 388 | ||
| 389 | /** v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control | 389 | /** v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control |
| 390 | * with driver specific menu. | 390 | * with driver specific menu. |
| @@ -395,9 +395,9 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | |||
| 395 | * @mask: The control's skip mask for menu controls. This makes it | 395 | * @mask: The control's skip mask for menu controls. This makes it |
| 396 | * easy to skip menu items that are not valid. If bit X is set, | 396 | * easy to skip menu items that are not valid. If bit X is set, |
| 397 | * then menu item X is skipped. Of course, this only works for | 397 | * then menu item X is skipped. Of course, this only works for |
| 398 | * menus with <= 32 menu items. There are no menus that come | 398 | * menus with <= 64 menu items. There are no menus that come |
| 399 | * close to that number, so this is OK. Should we ever need more, | 399 | * close to that number, so this is OK. Should we ever need more, |
| 400 | * then this will have to be extended to a u64 or a bit array. | 400 | * then this will have to be extended to a bit array. |
| 401 | * @def: The control's default value. | 401 | * @def: The control's default value. |
| 402 | * @qmenu: The new menu. | 402 | * @qmenu: The new menu. |
| 403 | * | 403 | * |
| @@ -406,8 +406,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | |||
| 406 | * | 406 | * |
| 407 | */ | 407 | */ |
| 408 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, | 408 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, |
| 409 | const struct v4l2_ctrl_ops *ops, u32 id, s32 max, | 409 | const struct v4l2_ctrl_ops *ops, u32 id, u8 max, |
| 410 | s32 mask, s32 def, const char * const *qmenu); | 410 | u64 mask, u8 def, const char * const *qmenu); |
| 411 | 411 | ||
| 412 | /** v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. | 412 | /** v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. |
| 413 | * @hdl: The control handler. | 413 | * @hdl: The control handler. |
| @@ -424,7 +424,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, | |||
| 424 | */ | 424 | */ |
| 425 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, | 425 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, |
| 426 | const struct v4l2_ctrl_ops *ops, | 426 | const struct v4l2_ctrl_ops *ops, |
| 427 | u32 id, s32 max, s32 def, const s64 *qmenu_int); | 427 | u32 id, u8 max, u8 def, const s64 *qmenu_int); |
| 428 | 428 | ||
| 429 | /** v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler. | 429 | /** v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler. |
| 430 | * @hdl: The control handler. | 430 | * @hdl: The control handler. |
| @@ -560,7 +560,7 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); | |||
| 560 | * take the lock itself. | 560 | * take the lock itself. |
| 561 | */ | 561 | */ |
| 562 | int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, | 562 | int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, |
| 563 | s32 min, s32 max, u32 step, s32 def); | 563 | s64 min, s64 max, u64 step, s64 def); |
| 564 | 564 | ||
| 565 | /** v4l2_ctrl_lock() - Helper function to lock the handler | 565 | /** v4l2_ctrl_lock() - Helper function to lock the handler |
| 566 | * associated with the control. | 566 | * associated with the control. |
