Commit ff144726 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vivid: use ARRAY_SIZE to calculate max control value

The max value of various menu controls is hardcoded, and it is easy to forget
to update it after adding a new menu item.

So use ARRAY_SIZE instead to calculate this value.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 9ec32cc7
...@@ -549,7 +549,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_osd_mode = { ...@@ -549,7 +549,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_osd_mode = {
.id = VIVID_CID_OSD_TEXT_MODE, .id = VIVID_CID_OSD_TEXT_MODE,
.name = "OSD Text Mode", .name = "OSD Text Mode",
.type = V4L2_CTRL_TYPE_MENU, .type = V4L2_CTRL_TYPE_MENU,
.max = 2, .max = ARRAY_SIZE(vivid_ctrl_osd_mode_strings) - 2,
.qmenu = vivid_ctrl_osd_mode_strings, .qmenu = vivid_ctrl_osd_mode_strings,
}; };
...@@ -641,7 +641,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_tstamp_src = { ...@@ -641,7 +641,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_tstamp_src = {
.id = VIVID_CID_TSTAMP_SRC, .id = VIVID_CID_TSTAMP_SRC,
.name = "Timestamp Source", .name = "Timestamp Source",
.type = V4L2_CTRL_TYPE_MENU, .type = V4L2_CTRL_TYPE_MENU,
.max = 1, .max = ARRAY_SIZE(vivid_ctrl_tstamp_src_strings) - 2,
.qmenu = vivid_ctrl_tstamp_src_strings, .qmenu = vivid_ctrl_tstamp_src_strings,
}; };
...@@ -713,7 +713,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_colorspace = { ...@@ -713,7 +713,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_colorspace = {
.id = VIVID_CID_COLORSPACE, .id = VIVID_CID_COLORSPACE,
.name = "Colorspace", .name = "Colorspace",
.type = V4L2_CTRL_TYPE_MENU, .type = V4L2_CTRL_TYPE_MENU,
.max = 7, .max = ARRAY_SIZE(vivid_ctrl_colorspace_strings) - 2,
.def = 2, .def = 2,
.qmenu = vivid_ctrl_colorspace_strings, .qmenu = vivid_ctrl_colorspace_strings,
}; };
...@@ -733,7 +733,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_xfer_func = { ...@@ -733,7 +733,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_xfer_func = {
.id = VIVID_CID_XFER_FUNC, .id = VIVID_CID_XFER_FUNC,
.name = "Transfer Function", .name = "Transfer Function",
.type = V4L2_CTRL_TYPE_MENU, .type = V4L2_CTRL_TYPE_MENU,
.max = 5, .max = ARRAY_SIZE(vivid_ctrl_xfer_func_strings) - 2,
.qmenu = vivid_ctrl_xfer_func_strings, .qmenu = vivid_ctrl_xfer_func_strings,
}; };
...@@ -755,7 +755,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_ycbcr_enc = { ...@@ -755,7 +755,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_ycbcr_enc = {
.id = VIVID_CID_YCBCR_ENC, .id = VIVID_CID_YCBCR_ENC,
.name = "Y'CbCr Encoding", .name = "Y'CbCr Encoding",
.type = V4L2_CTRL_TYPE_MENU, .type = V4L2_CTRL_TYPE_MENU,
.max = 8, .max = ARRAY_SIZE(vivid_ctrl_ycbcr_enc_strings) - 2,
.qmenu = vivid_ctrl_ycbcr_enc_strings, .qmenu = vivid_ctrl_ycbcr_enc_strings,
}; };
...@@ -771,7 +771,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_quantization = { ...@@ -771,7 +771,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_quantization = {
.id = VIVID_CID_QUANTIZATION, .id = VIVID_CID_QUANTIZATION,
.name = "Quantization", .name = "Quantization",
.type = V4L2_CTRL_TYPE_MENU, .type = V4L2_CTRL_TYPE_MENU,
.max = 2, .max = ARRAY_SIZE(vivid_ctrl_quantization_strings) - 2,
.qmenu = vivid_ctrl_quantization_strings, .qmenu = vivid_ctrl_quantization_strings,
}; };
...@@ -1089,7 +1089,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_std_signal_mode = { ...@@ -1089,7 +1089,7 @@ static const struct v4l2_ctrl_config vivid_ctrl_std_signal_mode = {
.id = VIVID_CID_STD_SIGNAL_MODE, .id = VIVID_CID_STD_SIGNAL_MODE,
.name = "Standard Signal Mode", .name = "Standard Signal Mode",
.type = V4L2_CTRL_TYPE_MENU, .type = V4L2_CTRL_TYPE_MENU,
.max = 5, .max = ARRAY_SIZE(vivid_ctrl_std_signal_mode_strings) - 2,
.menu_skip_mask = 1 << 3, .menu_skip_mask = 1 << 3,
.qmenu = vivid_ctrl_std_signal_mode_strings, .qmenu = vivid_ctrl_std_signal_mode_strings,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment