Lines Matching +full:aac +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-or-later
9 #define pr_fmt(fmt) "v4l2-ctrls: " fmt
15 #include <media/v4l2-ctrls.h>
16 #include <media/v4l2-dev.h>
17 #include <media/v4l2-device.h>
18 #include <media/v4l2-event.h>
19 #include <media/v4l2-fwnode.h>
20 #include <media/v4l2-ioctl.h>
23 if (!WARN_ON(!(vdev)) && ((vdev)->dev_debug & V4L2_DEV_DEBUG_CTRL)) \
29 (master->ops && master->ops->op)
31 (has_op(master, op) ? master->ops->op(master) : 0)
47 mode. */
50 return master->is_auto && master->cur.val == master->manual_mode_value; in is_cur_manual()
57 return master->is_auto && master->val == master->manual_mode_value; in is_new_manual()
73 "MPEG-1/2 Layer I", in v4l2_ctrl_get_menu()
74 "MPEG-1/2 Layer II", in v4l2_ctrl_get_menu()
75 "MPEG-1/2 Layer III", in v4l2_ctrl_get_menu()
76 "MPEG-2/4 AAC", in v4l2_ctrl_get_menu()
77 "AC-3", in v4l2_ctrl_get_menu()
175 "16-bit CRC", in v4l2_ctrl_get_menu()
188 "MPEG-1", in v4l2_ctrl_get_menu()
189 "MPEG-2", in v4l2_ctrl_get_menu()
190 "MPEG-4 AVC", in v4l2_ctrl_get_menu()
207 "MPEG-2 Program Stream", in v4l2_ctrl_get_menu()
208 "MPEG-2 Transport Stream", in v4l2_ctrl_get_menu()
209 "MPEG-1 System Stream", in v4l2_ctrl_get_menu()
210 "MPEG-2 DVD-compatible Stream", in v4l2_ctrl_get_menu()
211 "MPEG-1 VCD-compatible Stream", in v4l2_ctrl_get_menu()
212 "MPEG-2 SVCD-compatible Stream", in v4l2_ctrl_get_menu()
228 "Auto Mode", in v4l2_ctrl_get_menu()
229 "Manual Mode", in v4l2_ctrl_get_menu()
230 "Shutter Priority Mode", in v4l2_ctrl_get_menu()
231 "Aperture Priority Mode", in v4l2_ctrl_get_menu()
415 "Slice-Based", in v4l2_ctrl_get_menu()
416 "Frame-Based", in v4l2_ctrl_get_menu()
518 "DVI-D", in v4l2_ctrl_get_menu()
524 "RGB Limited Range (16-235)", in v4l2_ctrl_get_menu()
525 "RGB Full Range (0-255)", in v4l2_ctrl_get_menu()
596 "Slice-Based", in v4l2_ctrl_get_menu()
597 "Frame-Based", in v4l2_ctrl_get_menu()
786 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
818 case V4L2_CID_BAND_STOP_FILTER: return "Band-Stop Filter"; in v4l2_ctrl_get_name()
847 case V4L2_CID_MPEG_AUDIO_MODE: return "Audio Stereo Mode"; in v4l2_ctrl_get_name()
848 case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: return "Audio Stereo Mode Extension"; in v4l2_ctrl_get_name()
852 case V4L2_CID_MPEG_AUDIO_AAC_BITRATE: return "Audio AAC Bitrate"; in v4l2_ctrl_get_name()
853 case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: return "Audio AC-3 Bitrate"; in v4l2_ctrl_get_name()
862 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: return "Video Bitrate Mode"; in v4l2_ctrl_get_name()
874 case V4L2_CID_MPEG_VIDEO_HEADER_MODE: return "Sequence Header Mode"; in v4l2_ctrl_get_name()
876 case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE: return "Frame Skip Mode"; in v4l2_ctrl_get_name()
877 case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: return "H263 I-Frame QP Value"; in v4l2_ctrl_get_name()
878 case V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP: return "H263 P-Frame QP Value"; in v4l2_ctrl_get_name()
879 case V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP: return "H263 B-Frame QP Value"; in v4l2_ctrl_get_name()
882 case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: return "H264 I-Frame QP Value"; in v4l2_ctrl_get_name()
883 case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP: return "H264 P-Frame QP Value"; in v4l2_ctrl_get_name()
884 case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP: return "H264 B-Frame QP Value"; in v4l2_ctrl_get_name()
889 case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: return "H264 Entropy Mode"; in v4l2_ctrl_get_name()
890 case V4L2_CID_MPEG_VIDEO_H264_I_PERIOD: return "H264 I-Frame Period"; in v4l2_ctrl_get_name()
894 case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE: return "H264 Loop Filter Mode"; in v4l2_ctrl_get_name()
919 case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP: return "H264 I-Frame Minimum QP Value"; in v4l2_ctrl_get_name()
920 case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP: return "H264 I-Frame Maximum QP Value"; in v4l2_ctrl_get_name()
921 case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP: return "H264 P-Frame Minimum QP Value"; in v4l2_ctrl_get_name()
922 case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP: return "H264 P-Frame Maximum QP Value"; in v4l2_ctrl_get_name()
928 case V4L2_CID_MPEG_VIDEO_H264_DECODE_MODE: return "H264 Decode Mode"; in v4l2_ctrl_get_name()
933 case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: return "MPEG4 I-Frame QP Value"; in v4l2_ctrl_get_name()
934 case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP: return "MPEG4 P-Frame QP Value"; in v4l2_ctrl_get_name()
935 case V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP: return "MPEG4 B-Frame QP Value"; in v4l2_ctrl_get_name()
952 case V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS: return "MPEG-2 Slice Parameters"; in v4l2_ctrl_get_name()
953 case V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION: return "MPEG-2 Quantization Matrices"; in v4l2_ctrl_get_name()
955 case V4L2_CID_FWHT_I_FRAME_QP: return "FWHT I-Frame QP Value"; in v4l2_ctrl_get_name()
956 case V4L2_CID_FWHT_P_FRAME_QP: return "FWHT P-Frame QP Value"; in v4l2_ctrl_get_name()
960 case V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4: return "VPX Intra Mode Decision Disable"; in v4l2_ctrl_get_name()
968 case V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP: return "VPX I-Frame QP Value"; in v4l2_ctrl_get_name()
969 case V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP: return "VPX P-Frame QP Value"; in v4l2_ctrl_get_name()
976 case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP: return "HEVC I-Frame QP Value"; in v4l2_ctrl_get_name()
977 case V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP: return "HEVC P-Frame QP Value"; in v4l2_ctrl_get_name()
978 case V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP: return "HEVC B-Frame QP Value"; in v4l2_ctrl_get_name()
1015 case V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_PERIOD: return "HEVC Num of I-Frame b/w 2 IDR"; in v4l2_ctrl_get_name()
1019 case V4L2_CID_MPEG_VIDEO_REF_NUMBER_FOR_PFRAMES: return "Reference Frames for a P-Frame"; in v4l2_ctrl_get_name()
1024 case V4L2_CID_MPEG_VIDEO_HEVC_DECODE_MODE: return "HEVC Decode Mode"; in v4l2_ctrl_get_name()
1028 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
1054 case V4L2_CID_EXPOSURE_METERING: return "Exposure, Metering Mode"; in v4l2_ctrl_get_name()
1055 case V4L2_CID_SCENE_MODE: return "Scene Mode"; in v4l2_ctrl_get_name()
1068 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
1095 case V4L2_CID_TUNE_PREEMPHASIS: return "Pre-Emphasis"; in v4l2_ctrl_get_name()
1100 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
1102 case V4L2_CID_FLASH_LED_MODE: return "LED Mode"; in v4l2_ctrl_get_name()
1108 case V4L2_CID_FLASH_INTENSITY: return "Intensity, Flash Mode"; in v4l2_ctrl_get_name()
1109 case V4L2_CID_FLASH_TORCH_INTENSITY: return "Intensity, Torch Mode"; in v4l2_ctrl_get_name()
1116 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
1124 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
1135 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
1140 case V4L2_CID_DEINTERLACING_MODE: return "Deinterlacing Mode"; in v4l2_ctrl_get_name()
1144 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
1149 case V4L2_CID_DV_TX_MODE: return "Transmit Mode"; in v4l2_ctrl_get_name()
1157 case V4L2_CID_TUNE_DEEMPHASIS: return "De-Emphasis"; in v4l2_ctrl_get_name()
1178 /* Keep the order of the 'case's the same as in v4l2-controls.h! */ in v4l2_ctrl_get_name()
1180 case V4L2_CID_DETECT_MD_MODE: return "Motion Detection Mode"; in v4l2_ctrl_get_name()
1547 u32 flags = ctrl->flags; in user_flags()
1549 if (ctrl->is_ptr) in user_flags()
1558 ev->type = V4L2_EVENT_CTRL; in fill_event()
1559 ev->id = ctrl->id; in fill_event()
1560 ev->u.ctrl.changes = changes; in fill_event()
1561 ev->u.ctrl.type = ctrl->type; in fill_event()
1562 ev->u.ctrl.flags = user_flags(ctrl); in fill_event()
1563 if (ctrl->is_ptr) in fill_event()
1564 ev->u.ctrl.value64 = 0; in fill_event()
1566 ev->u.ctrl.value64 = *ctrl->p_cur.p_s64; in fill_event()
1567 ev->u.ctrl.minimum = ctrl->minimum; in fill_event()
1568 ev->u.ctrl.maximum = ctrl->maximum; in fill_event()
1569 if (ctrl->type == V4L2_CTRL_TYPE_MENU in fill_event()
1570 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in fill_event()
1571 ev->u.ctrl.step = 1; in fill_event()
1573 ev->u.ctrl.step = ctrl->step; in fill_event()
1574 ev->u.ctrl.default_value = ctrl->default_value; in fill_event()
1582 if (list_empty(&ctrl->ev_subs)) in send_event()
1586 list_for_each_entry(sev, &ctrl->ev_subs, node) in send_event()
1587 if (sev->fh != fh || in send_event()
1588 (sev->flags & V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK)) in send_event()
1589 v4l2_event_queue_fh(sev->fh, &ev); in send_event()
1596 switch (ctrl->type) { in std_equal()
1600 idx *= ctrl->elem_size; in std_equal()
1601 /* strings are always 0-terminated */ in std_equal()
1612 if (ctrl->is_int) in std_equal()
1614 idx *= ctrl->elem_size; in std_equal()
1616 ctrl->elem_size); in std_equal()
1624 void *p = ptr.p + idx * ctrl->elem_size; in std_init_compound()
1626 if (ctrl->p_def.p_const) in std_init_compound()
1627 memcpy(p, ctrl->p_def.p_const, ctrl->elem_size); in std_init_compound()
1629 memset(p, 0, ctrl->elem_size); in std_init_compound()
1636 switch ((u32)ctrl->type) { in std_init_compound()
1640 p_mpeg2_slice_params->sequence.chroma_format = 1; in std_init_compound()
1642 p_mpeg2_slice_params->picture.picture_structure = 1; in std_init_compound()
1643 p_mpeg2_slice_params->picture.picture_coding_type = in std_init_compound()
1652 switch (ctrl->type) { in std_init()
1654 idx *= ctrl->elem_size; in std_init()
1655 memset(ptr.p_char + idx, ' ', ctrl->minimum); in std_init()
1656 ptr.p_char[idx + ctrl->minimum] = '\0'; in std_init()
1659 ptr.p_s64[idx] = ctrl->default_value; in std_init()
1666 ptr.p_s32[idx] = ctrl->default_value; in std_init()
1673 ptr.p_u8[idx] = ctrl->default_value; in std_init()
1676 ptr.p_u16[idx] = ctrl->default_value; in std_init()
1679 ptr.p_u32[idx] = ctrl->default_value; in std_init()
1689 union v4l2_ctrl_ptr ptr = ctrl->p_cur; in std_log()
1691 if (ctrl->is_array) { in std_log()
1694 for (i = 0; i < ctrl->nr_of_dims; i++) in std_log()
1695 pr_cont("[%u]", ctrl->dims[i]); in std_log()
1699 switch (ctrl->type) { in std_log()
1707 pr_cont("%s", ctrl->qmenu[*ptr.p_s32]); in std_log()
1710 pr_cont("%lld", ctrl->qmenu_int[*ptr.p_s32]); in std_log()
1731 pr_cont("unknown type %d", ctrl->type); in std_log()
1739 * wrap-arounds.
1744 if ((ctrl)->maximum >= 0 && \
1745 val >= (ctrl)->maximum - (s32)((ctrl)->step / 2)) \
1746 val = (ctrl)->maximum; \
1748 val += (s32)((ctrl)->step / 2); \
1750 (ctrl)->minimum, (ctrl)->maximum); \
1751 offset = (val) - (ctrl)->minimum; \
1752 offset = (ctrl)->step * (offset / (u32)(ctrl)->step); \
1753 val = (ctrl)->minimum + offset; \
1779 void *p = ptr.p + idx * ctrl->elem_size; in std_validate_compound()
1782 switch ((u32)ctrl->type) { in std_validate_compound()
1786 switch (p_mpeg2_slice_params->sequence.chroma_format) { in std_validate_compound()
1792 return -EINVAL; in std_validate_compound()
1795 switch (p_mpeg2_slice_params->picture.intra_dc_precision) { in std_validate_compound()
1802 return -EINVAL; in std_validate_compound()
1805 switch (p_mpeg2_slice_params->picture.picture_structure) { in std_validate_compound()
1811 return -EINVAL; in std_validate_compound()
1814 switch (p_mpeg2_slice_params->picture.picture_coding_type) { in std_validate_compound()
1820 return -EINVAL; in std_validate_compound()
1848 &p_h264_dec_params->dpb[i]; in std_validate_compound()
1858 switch (p_vp8_frame_header->num_dct_parts) { in std_validate_compound()
1865 return -EINVAL; in std_validate_compound()
1867 zero_padding(p_vp8_frame_header->segment_header); in std_validate_compound()
1868 zero_padding(p_vp8_frame_header->lf_header); in std_validate_compound()
1869 zero_padding(p_vp8_frame_header->quant_header); in std_validate_compound()
1870 zero_padding(p_vp8_frame_header->entropy_header); in std_validate_compound()
1871 zero_padding(p_vp8_frame_header->coder_state); in std_validate_compound()
1877 if (!(p_hevc_sps->flags & V4L2_HEVC_SPS_FLAG_PCM_ENABLED)) { in std_validate_compound()
1878 p_hevc_sps->pcm_sample_bit_depth_luma_minus1 = 0; in std_validate_compound()
1879 p_hevc_sps->pcm_sample_bit_depth_chroma_minus1 = 0; in std_validate_compound()
1880 p_hevc_sps->log2_min_pcm_luma_coding_block_size_minus3 = 0; in std_validate_compound()
1881 p_hevc_sps->log2_diff_max_min_pcm_luma_coding_block_size = 0; in std_validate_compound()
1884 if (!(p_hevc_sps->flags & in std_validate_compound()
1886 p_hevc_sps->num_long_term_ref_pics_sps = 0; in std_validate_compound()
1892 if (!(p_hevc_pps->flags & in std_validate_compound()
1894 p_hevc_pps->diff_cu_qp_delta_depth = 0; in std_validate_compound()
1896 if (!(p_hevc_pps->flags & V4L2_HEVC_PPS_FLAG_TILES_ENABLED)) { in std_validate_compound()
1897 p_hevc_pps->num_tile_columns_minus1 = 0; in std_validate_compound()
1898 p_hevc_pps->num_tile_rows_minus1 = 0; in std_validate_compound()
1899 memset(&p_hevc_pps->column_width_minus1, 0, in std_validate_compound()
1900 sizeof(p_hevc_pps->column_width_minus1)); in std_validate_compound()
1901 memset(&p_hevc_pps->row_height_minus1, 0, in std_validate_compound()
1902 sizeof(p_hevc_pps->row_height_minus1)); in std_validate_compound()
1904 p_hevc_pps->flags &= in std_validate_compound()
1908 if (p_hevc_pps->flags & in std_validate_compound()
1910 p_hevc_pps->pps_beta_offset_div2 = 0; in std_validate_compound()
1911 p_hevc_pps->pps_tc_offset_div2 = 0; in std_validate_compound()
1920 if (p_hevc_slice_params->num_active_dpb_entries > in std_validate_compound()
1922 return -EINVAL; in std_validate_compound()
1924 zero_padding(p_hevc_slice_params->pred_weight_table); in std_validate_compound()
1926 for (i = 0; i < p_hevc_slice_params->num_active_dpb_entries; in std_validate_compound()
1929 &p_hevc_slice_params->dpb[i]; in std_validate_compound()
1939 if (!area->width || !area->height) in std_validate_compound()
1940 return -EINVAL; in std_validate_compound()
1944 return -EINVAL; in std_validate_compound()
1957 switch ((u32)ctrl->type) { in std_validate()
1966 if (ctrl->maximum >= 0 && val >= ctrl->maximum - (s64)(ctrl->step / 2)) in std_validate()
1967 val = ctrl->maximum; in std_validate()
1969 val += (s64)(ctrl->step / 2); in std_validate()
1970 val = clamp_t(s64, val, ctrl->minimum, ctrl->maximum); in std_validate()
1971 offset = val - ctrl->minimum; in std_validate()
1972 do_div(offset, ctrl->step); in std_validate()
1973 ptr.p_s64[idx] = ctrl->minimum + offset * ctrl->step; in std_validate()
1988 if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) in std_validate()
1989 return -ERANGE; in std_validate()
1990 if (ctrl->menu_skip_mask & (1ULL << ptr.p_s32[idx])) in std_validate()
1991 return -EINVAL; in std_validate()
1992 if (ctrl->type == V4L2_CTRL_TYPE_MENU && in std_validate()
1993 ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') in std_validate()
1994 return -EINVAL; in std_validate()
1998 ptr.p_s32[idx] &= ctrl->maximum; in std_validate()
2007 idx *= ctrl->elem_size; in std_validate()
2009 if (len < ctrl->minimum) in std_validate()
2010 return -ERANGE; in std_validate()
2011 if ((len - (u32)ctrl->minimum) % (u32)ctrl->step) in std_validate()
2012 return -ERANGE; in std_validate()
2034 if (ctrl->is_ptr && !ctrl->is_string) in ptr_to_user()
2035 return copy_to_user(c->ptr, ptr.p_const, c->size) ? in ptr_to_user()
2036 -EFAULT : 0; in ptr_to_user()
2038 switch (ctrl->type) { in ptr_to_user()
2041 if (c->size < len + 1) { in ptr_to_user()
2042 c->size = ctrl->elem_size; in ptr_to_user()
2043 return -ENOSPC; in ptr_to_user()
2045 return copy_to_user(c->string, ptr.p_char, len + 1) ? in ptr_to_user()
2046 -EFAULT : 0; in ptr_to_user()
2048 c->value64 = *ptr.p_s64; in ptr_to_user()
2051 c->value = *ptr.p_s32; in ptr_to_user()
2061 return ptr_to_user(c, ctrl, ctrl->p_cur); in cur_to_user()
2068 return ptr_to_user(c, ctrl, ctrl->p_new); in new_to_user()
2075 return ptr_to_user(c, ref->ctrl, ref->p_req); in req_to_user()
2083 for (idx = 0; idx < ctrl->elems; idx++) in def_to_user()
2084 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in def_to_user()
2086 return ptr_to_user(c, ctrl, ctrl->p_new); in def_to_user()
2089 /* Helper function: copy the caller-provider value to the given control value */
2097 ctrl->is_new = 1; in user_to_ptr()
2098 if (ctrl->is_ptr && !ctrl->is_string) { in user_to_ptr()
2101 ret = copy_from_user(ptr.p, c->ptr, c->size) ? -EFAULT : 0; in user_to_ptr()
2102 if (ret || !ctrl->is_array) in user_to_ptr()
2104 for (idx = c->size / ctrl->elem_size; idx < ctrl->elems; idx++) in user_to_ptr()
2105 ctrl->type_ops->init(ctrl, idx, ptr); in user_to_ptr()
2109 switch (ctrl->type) { in user_to_ptr()
2111 *ptr.p_s64 = c->value64; in user_to_ptr()
2114 size = c->size; in user_to_ptr()
2116 return -ERANGE; in user_to_ptr()
2117 if (size > ctrl->maximum + 1) in user_to_ptr()
2118 size = ctrl->maximum + 1; in user_to_ptr()
2119 ret = copy_from_user(ptr.p_char, c->string, size) ? -EFAULT : 0; in user_to_ptr()
2121 char last = ptr.p_char[size - 1]; in user_to_ptr()
2123 ptr.p_char[size - 1] = 0; in user_to_ptr()
2124 /* If the string was longer than ctrl->maximum, in user_to_ptr()
2126 if (strlen(ptr.p_char) == ctrl->maximum && last) in user_to_ptr()
2127 return -ERANGE; in user_to_ptr()
2131 *ptr.p_s32 = c->value; in user_to_ptr()
2137 /* Helper function: copy the caller-provider value as the new control value */
2141 return user_to_ptr(c, ctrl, ctrl->p_new); in user_to_new()
2150 memcpy(to.p, from.p_const, ctrl->elems * ctrl->elem_size); in ptr_to_ptr()
2162 changed = ctrl->has_changed; in new_to_cur()
2164 ptr_to_ptr(ctrl, ctrl->p_new, ctrl->p_cur); in new_to_cur()
2168 ctrl->flags &= in new_to_cur()
2170 if (!is_cur_manual(ctrl->cluster[0])) { in new_to_cur()
2171 ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; in new_to_cur()
2172 if (ctrl->cluster[0]->has_volatiles) in new_to_cur()
2173 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; in new_to_cur()
2180 if (!ctrl->is_new) in new_to_cur()
2184 if (ctrl->call_notify && changed && ctrl->handler->notify) in new_to_cur()
2185 ctrl->handler->notify(ctrl, ctrl->handler->notify_priv); in new_to_cur()
2194 ptr_to_ptr(ctrl, ctrl->p_cur, ctrl->p_new); in cur_to_new()
2202 ptr_to_ptr(ref->ctrl, ref->ctrl->p_new, ref->p_req); in new_to_req()
2203 ref->req = ref; in new_to_req()
2211 if (ref->req) in req_to_new()
2212 ptr_to_ptr(ref->ctrl, ref->req->p_req, ref->ctrl->p_new); in req_to_new()
2214 ptr_to_ptr(ref->ctrl, ref->ctrl->p_cur, ref->ctrl->p_new); in req_to_new()
2217 /* Return non-zero if one or more of the controls in the cluster has a new
2225 for (i = 0; i < master->ncontrols; i++) { in cluster_changed()
2226 struct v4l2_ctrl *ctrl = master->cluster[i]; in cluster_changed()
2232 if (ctrl->flags & V4L2_CTRL_FLAG_EXECUTE_ON_WRITE) in cluster_changed()
2239 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in cluster_changed()
2240 ctrl->has_changed = false; in cluster_changed()
2244 for (idx = 0; !ctrl_changed && idx < ctrl->elems; idx++) in cluster_changed()
2245 ctrl_changed = !ctrl->type_ops->equal(ctrl, idx, in cluster_changed()
2246 ctrl->p_cur, ctrl->p_new); in cluster_changed()
2247 ctrl->has_changed = ctrl_changed; in cluster_changed()
2248 changed |= ctrl->has_changed; in cluster_changed()
2260 return -ERANGE; in check_range()
2268 return -ERANGE; in check_range()
2272 return -ERANGE; in check_range()
2277 return -ERANGE; in check_range()
2281 return -EINVAL; in check_range()
2285 return -ERANGE; in check_range()
2298 for (idx = 0; !err && idx < ctrl->elems; idx++) in validate_new()
2299 err = ctrl->type_ops->validate(ctrl, idx, p_new); in validate_new()
2305 return list_entry(node, struct v4l2_ctrl_ref, node)->ctrl->id; in node2id()
2311 if (hdl->error == 0) in handler_set_err()
2312 hdl->error = err; in handler_set_err()
2321 mutex_init(&hdl->_lock); in v4l2_ctrl_handler_init_class()
2322 hdl->lock = &hdl->_lock; in v4l2_ctrl_handler_init_class()
2323 lockdep_set_class_and_name(hdl->lock, key, name); in v4l2_ctrl_handler_init_class()
2324 INIT_LIST_HEAD(&hdl->ctrls); in v4l2_ctrl_handler_init_class()
2325 INIT_LIST_HEAD(&hdl->ctrl_refs); in v4l2_ctrl_handler_init_class()
2326 INIT_LIST_HEAD(&hdl->requests); in v4l2_ctrl_handler_init_class()
2327 INIT_LIST_HEAD(&hdl->requests_queued); in v4l2_ctrl_handler_init_class()
2328 hdl->request_is_queued = false; in v4l2_ctrl_handler_init_class()
2329 hdl->nr_of_buckets = 1 + nr_of_controls_hint / 8; in v4l2_ctrl_handler_init_class()
2330 hdl->buckets = kvmalloc_array(hdl->nr_of_buckets, in v4l2_ctrl_handler_init_class()
2331 sizeof(hdl->buckets[0]), in v4l2_ctrl_handler_init_class()
2333 hdl->error = hdl->buckets ? 0 : -ENOMEM; in v4l2_ctrl_handler_init_class()
2334 media_request_object_init(&hdl->req_obj); in v4l2_ctrl_handler_init_class()
2335 return hdl->error; in v4l2_ctrl_handler_init_class()
2346 if (hdl == NULL || hdl->buckets == NULL) in v4l2_ctrl_handler_free()
2349 if (!hdl->req_obj.req && !list_empty(&hdl->requests)) { in v4l2_ctrl_handler_free()
2352 list_for_each_entry_safe(req, next_req, &hdl->requests, requests) { in v4l2_ctrl_handler_free()
2353 media_request_object_unbind(&req->req_obj); in v4l2_ctrl_handler_free()
2354 media_request_object_put(&req->req_obj); in v4l2_ctrl_handler_free()
2357 mutex_lock(hdl->lock); in v4l2_ctrl_handler_free()
2359 list_for_each_entry_safe(ref, next_ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_handler_free()
2360 list_del(&ref->node); in v4l2_ctrl_handler_free()
2364 list_for_each_entry_safe(ctrl, next_ctrl, &hdl->ctrls, node) { in v4l2_ctrl_handler_free()
2365 list_del(&ctrl->node); in v4l2_ctrl_handler_free()
2366 list_for_each_entry_safe(sev, next_sev, &ctrl->ev_subs, node) in v4l2_ctrl_handler_free()
2367 list_del(&sev->node); in v4l2_ctrl_handler_free()
2370 kvfree(hdl->buckets); in v4l2_ctrl_handler_free()
2371 hdl->buckets = NULL; in v4l2_ctrl_handler_free()
2372 hdl->cached = NULL; in v4l2_ctrl_handler_free()
2373 hdl->error = 0; in v4l2_ctrl_handler_free()
2374 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_free()
2375 mutex_destroy(&hdl->_lock); in v4l2_ctrl_handler_free()
2383 We just find the n-th private user control. It's O(N), but that should not
2390 id -= V4L2_CID_PRIVATE_BASE; in find_private_ref()
2391 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in find_private_ref()
2394 if (V4L2_CTRL_ID2WHICH(ref->ctrl->id) == V4L2_CTRL_CLASS_USER && in find_private_ref()
2395 V4L2_CTRL_DRIVER_PRIV(ref->ctrl->id)) { in find_private_ref()
2396 if (!ref->ctrl->is_int) in find_private_ref()
2400 id--; in find_private_ref()
2414 /* Old-style private controls need special handling */ in find_ref()
2417 bucket = id % hdl->nr_of_buckets; in find_ref()
2420 if (hdl->cached && hdl->cached->ctrl->id == id) in find_ref()
2421 return hdl->cached; in find_ref()
2424 ref = hdl->buckets ? hdl->buckets[bucket] : NULL; in find_ref()
2425 while (ref && ref->ctrl->id != id) in find_ref()
2426 ref = ref->next; in find_ref()
2429 hdl->cached = ref; /* cache it! */ in find_ref()
2440 mutex_lock(hdl->lock); in find_ref_lock()
2442 mutex_unlock(hdl->lock); in find_ref_lock()
2452 return ref ? ref->ctrl : NULL; in v4l2_ctrl_find()
2464 u32 id = ctrl->id; in handler_new_ref()
2466 int bucket = id % hdl->nr_of_buckets; /* which bucket to use */ in handler_new_ref()
2476 if (ctrl->type < V4L2_CTRL_COMPOUND_TYPES && in handler_new_ref()
2479 return hdl->error; in handler_new_ref()
2481 if (hdl->error) in handler_new_ref()
2482 return hdl->error; in handler_new_ref()
2485 size_extra_req = ctrl->elems * ctrl->elem_size; in handler_new_ref()
2488 return handler_set_err(hdl, -ENOMEM); in handler_new_ref()
2489 new_ref->ctrl = ctrl; in handler_new_ref()
2490 new_ref->from_other_dev = from_other_dev; in handler_new_ref()
2492 new_ref->p_req.p = &new_ref[1]; in handler_new_ref()
2494 INIT_LIST_HEAD(&new_ref->node); in handler_new_ref()
2496 mutex_lock(hdl->lock); in handler_new_ref()
2502 if (list_empty(&hdl->ctrl_refs) || id > node2id(hdl->ctrl_refs.prev)) { in handler_new_ref()
2503 list_add_tail(&new_ref->node, &hdl->ctrl_refs); in handler_new_ref()
2508 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in handler_new_ref()
2509 if (ref->ctrl->id < id) in handler_new_ref()
2512 if (ref->ctrl->id == id) { in handler_new_ref()
2516 list_add(&new_ref->node, ref->node.prev); in handler_new_ref()
2522 new_ref->next = hdl->buckets[bucket]; in handler_new_ref()
2523 hdl->buckets[bucket] = new_ref; in handler_new_ref()
2526 if (ctrl->handler == hdl) { in handler_new_ref()
2528 * new_ref->ctrl is basically a cluster array with one in handler_new_ref()
2532 ctrl->cluster = &new_ref->ctrl; in handler_new_ref()
2533 ctrl->ncontrols = 1; in handler_new_ref()
2537 mutex_unlock(hdl->lock); in handler_new_ref()
2562 if (hdl->error) in v4l2_ctrl_new()
2644 handler_set_err(hdl, -ERANGE); in v4l2_ctrl_new()
2655 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new()
2676 handler_set_err(hdl, -ENOMEM); in v4l2_ctrl_new()
2680 INIT_LIST_HEAD(&ctrl->node); in v4l2_ctrl_new()
2681 INIT_LIST_HEAD(&ctrl->ev_subs); in v4l2_ctrl_new()
2682 ctrl->handler = hdl; in v4l2_ctrl_new()
2683 ctrl->ops = ops; in v4l2_ctrl_new()
2684 ctrl->type_ops = type_ops ? type_ops : &std_type_ops; in v4l2_ctrl_new()
2685 ctrl->id = id; in v4l2_ctrl_new()
2686 ctrl->name = name; in v4l2_ctrl_new()
2687 ctrl->type = type; in v4l2_ctrl_new()
2688 ctrl->flags = flags; in v4l2_ctrl_new()
2689 ctrl->minimum = min; in v4l2_ctrl_new()
2690 ctrl->maximum = max; in v4l2_ctrl_new()
2691 ctrl->step = step; in v4l2_ctrl_new()
2692 ctrl->default_value = def; in v4l2_ctrl_new()
2693 ctrl->is_string = !is_array && type == V4L2_CTRL_TYPE_STRING; in v4l2_ctrl_new()
2694 ctrl->is_ptr = is_array || type >= V4L2_CTRL_COMPOUND_TYPES || ctrl->is_string; in v4l2_ctrl_new()
2695 ctrl->is_int = !ctrl->is_ptr && type != V4L2_CTRL_TYPE_INTEGER64; in v4l2_ctrl_new()
2696 ctrl->is_array = is_array; in v4l2_ctrl_new()
2697 ctrl->elems = elems; in v4l2_ctrl_new()
2698 ctrl->nr_of_dims = nr_of_dims; in v4l2_ctrl_new()
2700 memcpy(ctrl->dims, dims, nr_of_dims * sizeof(dims[0])); in v4l2_ctrl_new()
2701 ctrl->elem_size = elem_size; in v4l2_ctrl_new()
2703 ctrl->qmenu = qmenu; in v4l2_ctrl_new()
2705 ctrl->qmenu_int = qmenu_int; in v4l2_ctrl_new()
2706 ctrl->priv = priv; in v4l2_ctrl_new()
2707 ctrl->cur.val = ctrl->val = def; in v4l2_ctrl_new()
2710 if (!ctrl->is_int) { in v4l2_ctrl_new()
2711 ctrl->p_new.p = data; in v4l2_ctrl_new()
2712 ctrl->p_cur.p = data + tot_ctrl_size; in v4l2_ctrl_new()
2714 ctrl->p_new.p = &ctrl->val; in v4l2_ctrl_new()
2715 ctrl->p_cur.p = &ctrl->cur.val; in v4l2_ctrl_new()
2719 ctrl->p_def.p = ctrl->p_cur.p + tot_ctrl_size; in v4l2_ctrl_new()
2720 memcpy(ctrl->p_def.p, p_def.p_const, elem_size); in v4l2_ctrl_new()
2724 ctrl->type_ops->init(ctrl, idx, ctrl->p_cur); in v4l2_ctrl_new()
2725 ctrl->type_ops->init(ctrl, idx, ctrl->p_new); in v4l2_ctrl_new()
2732 mutex_lock(hdl->lock); in v4l2_ctrl_new()
2733 list_add_tail(&ctrl->node, &hdl->ctrls); in v4l2_ctrl_new()
2734 mutex_unlock(hdl->lock); in v4l2_ctrl_new()
2743 const char *name = cfg->name; in v4l2_ctrl_new_custom()
2744 const char * const *qmenu = cfg->qmenu; in v4l2_ctrl_new_custom()
2745 const s64 *qmenu_int = cfg->qmenu_int; in v4l2_ctrl_new_custom()
2746 enum v4l2_ctrl_type type = cfg->type; in v4l2_ctrl_new_custom()
2747 u32 flags = cfg->flags; in v4l2_ctrl_new_custom()
2748 s64 min = cfg->min; in v4l2_ctrl_new_custom()
2749 s64 max = cfg->max; in v4l2_ctrl_new_custom()
2750 u64 step = cfg->step; in v4l2_ctrl_new_custom()
2751 s64 def = cfg->def; in v4l2_ctrl_new_custom()
2754 v4l2_ctrl_fill(cfg->id, &name, &type, &min, &max, &step, in v4l2_ctrl_new_custom()
2762 WARN_ON(cfg->menu_skip_mask); in v4l2_ctrl_new_custom()
2764 qmenu = v4l2_ctrl_get_menu(cfg->id); in v4l2_ctrl_new_custom()
2766 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_custom()
2770 ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->type_ops, cfg->id, name, in v4l2_ctrl_new_custom()
2772 is_menu ? cfg->menu_skip_mask : step, def, in v4l2_ctrl_new_custom()
2773 cfg->dims, cfg->elem_size, in v4l2_ctrl_new_custom()
2774 flags, qmenu, qmenu_int, cfg->p_def, priv); in v4l2_ctrl_new_custom()
2776 ctrl->is_private = cfg->is_private; in v4l2_ctrl_new_custom()
2781 /* Helper function for standard non-menu controls */
2794 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std()
2827 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu()
2853 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
2859 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_menu_items()
2881 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_std_compound()
2905 handler_set_err(hdl, -EINVAL); in v4l2_ctrl_new_int_menu()
2926 if (hdl->error) in v4l2_ctrl_add_handler()
2927 return hdl->error; in v4l2_ctrl_add_handler()
2928 mutex_lock(add->lock); in v4l2_ctrl_add_handler()
2929 list_for_each_entry(ref, &add->ctrl_refs, node) { in v4l2_ctrl_add_handler()
2930 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_add_handler()
2932 /* Skip handler-private controls. */ in v4l2_ctrl_add_handler()
2933 if (ctrl->is_private) in v4l2_ctrl_add_handler()
2936 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in v4l2_ctrl_add_handler()
2945 mutex_unlock(add->lock); in v4l2_ctrl_add_handler()
2952 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_TX) in v4l2_ctrl_radio_filter()
2954 if (V4L2_CTRL_ID2WHICH(ctrl->id) == V4L2_CTRL_CLASS_FM_RX) in v4l2_ctrl_radio_filter()
2956 switch (ctrl->id) { in v4l2_ctrl_radio_filter()
2983 controls[i]->cluster = controls; in v4l2_ctrl_cluster()
2984 controls[i]->ncontrols = ncontrols; in v4l2_ctrl_cluster()
2985 if (controls[i]->flags & V4L2_CTRL_FLAG_VOLATILE) in v4l2_ctrl_cluster()
2989 controls[0]->has_volatiles = has_volatiles; in v4l2_ctrl_cluster()
3002 WARN_ON(manual_val < master->minimum || manual_val > master->maximum); in v4l2_ctrl_auto_cluster()
3004 master->is_auto = true; in v4l2_ctrl_auto_cluster()
3005 master->has_volatiles = set_volatile; in v4l2_ctrl_auto_cluster()
3006 master->manual_mode_value = manual_val; in v4l2_ctrl_auto_cluster()
3007 master->flags |= V4L2_CTRL_FLAG_UPDATE; in v4l2_ctrl_auto_cluster()
3015 controls[i]->flags |= flag; in v4l2_ctrl_auto_cluster()
3031 old = test_and_set_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
3034 old = test_and_clear_bit(4, &ctrl->flags); in v4l2_ctrl_activate()
3047 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_grab()
3051 old = test_and_set_bit(1, &ctrl->flags); in __v4l2_ctrl_grab()
3054 old = test_and_clear_bit(1, &ctrl->flags); in __v4l2_ctrl_grab()
3064 if (ctrl->flags & (V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_WRITE_ONLY)) in log_ctrl()
3066 if (ctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) in log_ctrl()
3069 pr_info("%s%s%s: ", prefix, colon, ctrl->name); in log_ctrl()
3071 ctrl->type_ops->log(ctrl); in log_ctrl()
3073 if (ctrl->flags & (V4L2_CTRL_FLAG_INACTIVE | in log_ctrl()
3076 if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE) in log_ctrl()
3078 if (ctrl->flags & V4L2_CTRL_FLAG_GRABBED) in log_ctrl()
3080 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) in log_ctrl()
3099 if (len && prefix[len - 1] != ' ') in v4l2_ctrl_handler_log_status()
3101 mutex_lock(hdl->lock); in v4l2_ctrl_handler_log_status()
3102 list_for_each_entry(ctrl, &hdl->ctrls, node) in v4l2_ctrl_handler_log_status()
3103 if (!(ctrl->flags & V4L2_CTRL_FLAG_DISABLED)) in v4l2_ctrl_handler_log_status()
3105 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_log_status()
3111 v4l2_ctrl_handler_log_status(sd->ctrl_handler, sd->name); in v4l2_ctrl_subdev_log_status()
3125 lockdep_assert_held(hdl->lock); in __v4l2_ctrl_handler_setup()
3127 list_for_each_entry(ctrl, &hdl->ctrls, node) in __v4l2_ctrl_handler_setup()
3128 ctrl->done = false; in __v4l2_ctrl_handler_setup()
3130 list_for_each_entry(ctrl, &hdl->ctrls, node) { in __v4l2_ctrl_handler_setup()
3131 struct v4l2_ctrl *master = ctrl->cluster[0]; in __v4l2_ctrl_handler_setup()
3135 /* Skip button controls and read-only controls. */ in __v4l2_ctrl_handler_setup()
3136 if (ctrl->done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in __v4l2_ctrl_handler_setup()
3137 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in __v4l2_ctrl_handler_setup()
3140 for (i = 0; i < master->ncontrols; i++) { in __v4l2_ctrl_handler_setup()
3141 if (master->cluster[i]) { in __v4l2_ctrl_handler_setup()
3142 cur_to_new(master->cluster[i]); in __v4l2_ctrl_handler_setup()
3143 master->cluster[i]->is_new = 1; in __v4l2_ctrl_handler_setup()
3144 master->cluster[i]->done = true; in __v4l2_ctrl_handler_setup()
3163 mutex_lock(hdl->lock); in v4l2_ctrl_handler_setup()
3165 mutex_unlock(hdl->lock); in v4l2_ctrl_handler_setup()
3175 u32 id = qc->id & V4L2_CTRL_ID_MASK; in v4l2_query_ext_ctrl()
3180 return -EINVAL; in v4l2_query_ext_ctrl()
3182 mutex_lock(hdl->lock); in v4l2_query_ext_ctrl()
3187 if ((qc->id & next_flags) && !list_empty(&hdl->ctrl_refs)) { in v4l2_query_ext_ctrl()
3193 if ((qc->id & next_flags) == V4L2_CTRL_FLAG_NEXT_COMPOUND) { in v4l2_query_ext_ctrl()
3196 } else if ((qc->id & next_flags) == next_flags) { in v4l2_query_ext_ctrl()
3201 /* Find the next control with ID > qc->id */ in v4l2_query_ext_ctrl()
3204 if (id >= node2id(hdl->ctrl_refs.prev)) { in v4l2_query_ext_ctrl()
3209 list_for_each_entry_continue(ref, &hdl->ctrl_refs, node) { in v4l2_query_ext_ctrl()
3210 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
3211 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
3212 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
3216 if (&ref->node == &hdl->ctrl_refs) in v4l2_query_ext_ctrl()
3223 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in v4l2_query_ext_ctrl()
3224 is_compound = ref->ctrl->is_array || in v4l2_query_ext_ctrl()
3225 ref->ctrl->type >= V4L2_CTRL_COMPOUND_TYPES; in v4l2_query_ext_ctrl()
3226 if (id < ref->ctrl->id && in v4l2_query_ext_ctrl()
3230 if (&ref->node == &hdl->ctrl_refs) in v4l2_query_ext_ctrl()
3234 mutex_unlock(hdl->lock); in v4l2_query_ext_ctrl()
3237 return -EINVAL; in v4l2_query_ext_ctrl()
3239 ctrl = ref->ctrl; in v4l2_query_ext_ctrl()
3242 qc->id = id; in v4l2_query_ext_ctrl()
3244 qc->id = ctrl->id; in v4l2_query_ext_ctrl()
3245 strscpy(qc->name, ctrl->name, sizeof(qc->name)); in v4l2_query_ext_ctrl()
3246 qc->flags = user_flags(ctrl); in v4l2_query_ext_ctrl()
3247 qc->type = ctrl->type; in v4l2_query_ext_ctrl()
3248 qc->elem_size = ctrl->elem_size; in v4l2_query_ext_ctrl()
3249 qc->elems = ctrl->elems; in v4l2_query_ext_ctrl()
3250 qc->nr_of_dims = ctrl->nr_of_dims; in v4l2_query_ext_ctrl()
3251 memcpy(qc->dims, ctrl->dims, qc->nr_of_dims * sizeof(qc->dims[0])); in v4l2_query_ext_ctrl()
3252 qc->minimum = ctrl->minimum; in v4l2_query_ext_ctrl()
3253 qc->maximum = ctrl->maximum; in v4l2_query_ext_ctrl()
3254 qc->default_value = ctrl->default_value; in v4l2_query_ext_ctrl()
3255 if (ctrl->type == V4L2_CTRL_TYPE_MENU in v4l2_query_ext_ctrl()
3256 || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU) in v4l2_query_ext_ctrl()
3257 qc->step = 1; in v4l2_query_ext_ctrl()
3259 qc->step = ctrl->step; in v4l2_query_ext_ctrl()
3267 struct v4l2_query_ext_ctrl qec = { qc->id }; in v4l2_queryctrl()
3274 qc->id = qec.id; in v4l2_queryctrl()
3275 qc->type = qec.type; in v4l2_queryctrl()
3276 qc->flags = qec.flags; in v4l2_queryctrl()
3277 strscpy(qc->name, qec.name, sizeof(qc->name)); in v4l2_queryctrl()
3278 switch (qc->type) { in v4l2_queryctrl()
3285 qc->minimum = qec.minimum; in v4l2_queryctrl()
3286 qc->maximum = qec.maximum; in v4l2_queryctrl()
3287 qc->step = qec.step; in v4l2_queryctrl()
3288 qc->default_value = qec.default_value; in v4l2_queryctrl()
3291 qc->minimum = 0; in v4l2_queryctrl()
3292 qc->maximum = 0; in v4l2_queryctrl()
3293 qc->step = 0; in v4l2_queryctrl()
3294 qc->default_value = 0; in v4l2_queryctrl()
3305 u32 i = qm->index; in v4l2_querymenu()
3307 ctrl = v4l2_ctrl_find(hdl, qm->id); in v4l2_querymenu()
3309 return -EINVAL; in v4l2_querymenu()
3311 qm->reserved = 0; in v4l2_querymenu()
3313 switch (ctrl->type) { in v4l2_querymenu()
3315 if (ctrl->qmenu == NULL) in v4l2_querymenu()
3316 return -EINVAL; in v4l2_querymenu()
3319 if (ctrl->qmenu_int == NULL) in v4l2_querymenu()
3320 return -EINVAL; in v4l2_querymenu()
3323 return -EINVAL; in v4l2_querymenu()
3326 if (i < ctrl->minimum || i > ctrl->maximum) in v4l2_querymenu()
3327 return -EINVAL; in v4l2_querymenu()
3330 if (ctrl->menu_skip_mask & (1ULL << i)) in v4l2_querymenu()
3331 return -EINVAL; in v4l2_querymenu()
3333 if (ctrl->type == V4L2_CTRL_TYPE_MENU) { in v4l2_querymenu()
3334 if (ctrl->qmenu[i] == NULL || ctrl->qmenu[i][0] == '\0') in v4l2_querymenu()
3335 return -EINVAL; in v4l2_querymenu()
3336 strscpy(qm->name, ctrl->qmenu[i], sizeof(qm->name)); in v4l2_querymenu()
3338 qm->value = ctrl->qmenu_int[i]; in v4l2_querymenu()
3351 return -EINVAL; in v4l2_ctrl_request_clone()
3353 if (hdl->error) in v4l2_ctrl_request_clone()
3354 return hdl->error; in v4l2_ctrl_request_clone()
3356 WARN_ON(hdl->lock != &hdl->_lock); in v4l2_ctrl_request_clone()
3358 mutex_lock(from->lock); in v4l2_ctrl_request_clone()
3359 list_for_each_entry(ref, &from->ctrl_refs, node) { in v4l2_ctrl_request_clone()
3360 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_clone()
3364 if (ref->from_other_dev) in v4l2_ctrl_request_clone()
3367 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON) in v4l2_ctrl_request_clone()
3373 mutex_unlock(from->lock); in v4l2_ctrl_request_clone()
3381 struct v4l2_ctrl_handler *main_hdl = obj->priv; in v4l2_ctrl_request_queue()
3385 mutex_lock(main_hdl->lock); in v4l2_ctrl_request_queue()
3386 if (list_empty(&main_hdl->requests_queued)) in v4l2_ctrl_request_queue()
3389 prev_hdl = list_last_entry(&main_hdl->requests_queued, in v4l2_ctrl_request_queue()
3396 mutex_lock(prev_hdl->lock); in v4l2_ctrl_request_queue()
3397 ref_ctrl_prev = list_first_entry(&prev_hdl->ctrl_refs, in v4l2_ctrl_request_queue()
3399 list_for_each_entry(ref_ctrl, &hdl->ctrl_refs, node) { in v4l2_ctrl_request_queue()
3400 if (ref_ctrl->req) in v4l2_ctrl_request_queue()
3402 while (ref_ctrl_prev->ctrl->id < ref_ctrl->ctrl->id) { in v4l2_ctrl_request_queue()
3404 if (list_is_last(&ref_ctrl_prev->node, in v4l2_ctrl_request_queue()
3405 &prev_hdl->ctrl_refs)) in v4l2_ctrl_request_queue()
3409 if (WARN_ON(ref_ctrl_prev->ctrl->id != ref_ctrl->ctrl->id)) in v4l2_ctrl_request_queue()
3411 ref_ctrl->req = ref_ctrl_prev->req; in v4l2_ctrl_request_queue()
3413 mutex_unlock(prev_hdl->lock); in v4l2_ctrl_request_queue()
3415 list_add_tail(&hdl->requests_queued, &main_hdl->requests_queued); in v4l2_ctrl_request_queue()
3416 hdl->request_is_queued = true; in v4l2_ctrl_request_queue()
3417 mutex_unlock(main_hdl->lock); in v4l2_ctrl_request_queue()
3424 struct v4l2_ctrl_handler *main_hdl = obj->priv; in v4l2_ctrl_request_unbind()
3426 list_del_init(&hdl->requests); in v4l2_ctrl_request_unbind()
3427 mutex_lock(main_hdl->lock); in v4l2_ctrl_request_unbind()
3428 if (hdl->request_is_queued) { in v4l2_ctrl_request_unbind()
3429 list_del_init(&hdl->requests_queued); in v4l2_ctrl_request_unbind()
3430 hdl->request_is_queued = false; in v4l2_ctrl_request_unbind()
3432 mutex_unlock(main_hdl->lock); in v4l2_ctrl_request_unbind()
3455 if (WARN_ON(req->state != MEDIA_REQUEST_STATE_VALIDATING && in v4l2_ctrl_request_hdl_find()
3456 req->state != MEDIA_REQUEST_STATE_QUEUED)) in v4l2_ctrl_request_hdl_find()
3471 return (ref && ref->req == ref) ? ref->ctrl : NULL; in v4l2_ctrl_request_hdl_ctrl_find()
3485 from, false, &hdl->req_obj); in v4l2_ctrl_request_bind()
3487 list_add_tail(&hdl->requests, &from->requests); in v4l2_ctrl_request_bind()
3494 It is not a fully atomic operation, just best-effort only. After all, if
3505 in case of low-level errors.
3543 for (i = 0, h = helpers; i < cs->count; i++, h++) { in prepare_ext_ctrls()
3544 struct v4l2_ext_control *c = &cs->controls[i]; in prepare_ext_ctrls()
3547 u32 id = c->id & V4L2_CTRL_ID_MASK; in prepare_ext_ctrls()
3549 cs->error_idx = i; in prepare_ext_ctrls()
3551 if (cs->which && in prepare_ext_ctrls()
3552 cs->which != V4L2_CTRL_WHICH_DEF_VAL && in prepare_ext_ctrls()
3553 cs->which != V4L2_CTRL_WHICH_REQUEST_VAL && in prepare_ext_ctrls()
3554 V4L2_CTRL_ID2WHICH(id) != cs->which) { in prepare_ext_ctrls()
3557 cs->which, id); in prepare_ext_ctrls()
3558 return -EINVAL; in prepare_ext_ctrls()
3561 /* Old-style private controls are not allowed for in prepare_ext_ctrls()
3565 "old-style private controls not allowed\n"); in prepare_ext_ctrls()
3566 return -EINVAL; in prepare_ext_ctrls()
3571 return -EINVAL; in prepare_ext_ctrls()
3573 h->ref = ref; in prepare_ext_ctrls()
3574 ctrl = ref->ctrl; in prepare_ext_ctrls()
3575 if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) { in prepare_ext_ctrls()
3577 return -EINVAL; in prepare_ext_ctrls()
3580 if (ctrl->cluster[0]->ncontrols > 1) in prepare_ext_ctrls()
3582 if (ctrl->cluster[0] != ctrl) in prepare_ext_ctrls()
3583 ref = find_ref_lock(hdl, ctrl->cluster[0]->id); in prepare_ext_ctrls()
3584 if (ctrl->is_ptr && !ctrl->is_string) { in prepare_ext_ctrls()
3585 unsigned tot_size = ctrl->elems * ctrl->elem_size; in prepare_ext_ctrls()
3587 if (c->size < tot_size) { in prepare_ext_ctrls()
3593 c->size = tot_size; in prepare_ext_ctrls()
3594 return -ENOSPC; in prepare_ext_ctrls()
3598 id, c->size, tot_size); in prepare_ext_ctrls()
3599 return -EFAULT; in prepare_ext_ctrls()
3601 c->size = tot_size; in prepare_ext_ctrls()
3604 h->mref = ref; in prepare_ext_ctrls()
3608 h->next = 0; in prepare_ext_ctrls()
3611 /* We are done if there were no controls that belong to a multi- in prepare_ext_ctrls()
3620 mutex_lock(hdl->lock); in prepare_ext_ctrls()
3623 for (i = 0; i < cs->count; i++) in prepare_ext_ctrls()
3624 helpers[i].mref->helper = NULL; in prepare_ext_ctrls()
3625 for (i = 0, h = helpers; i < cs->count; i++, h++) { in prepare_ext_ctrls()
3626 struct v4l2_ctrl_ref *mref = h->mref; in prepare_ext_ctrls()
3628 /* If the mref->helper is set, then it points to an earlier in prepare_ext_ctrls()
3630 if (mref->helper) { in prepare_ext_ctrls()
3631 /* Set the next field of mref->helper to the current in prepare_ext_ctrls()
3634 mref->helper->next = i; in prepare_ext_ctrls()
3637 h->mref = NULL; in prepare_ext_ctrls()
3640 mref->helper = h; in prepare_ext_ctrls()
3642 mutex_unlock(hdl->lock); in prepare_ext_ctrls()
3646 /* Handles the corner case where cs->count == 0. It checks whether the
3654 return find_ref_lock(hdl, which | 1) ? 0 : -EINVAL; in class_check()
3668 def_value = (cs->which == V4L2_CTRL_WHICH_DEF_VAL); in v4l2_g_ext_ctrls_common()
3670 cs->error_idx = cs->count; in v4l2_g_ext_ctrls_common()
3671 cs->which = V4L2_CTRL_ID2WHICH(cs->which); in v4l2_g_ext_ctrls_common()
3674 return -EINVAL; in v4l2_g_ext_ctrls_common()
3676 if (cs->count == 0) in v4l2_g_ext_ctrls_common()
3677 return class_check(hdl, cs->which); in v4l2_g_ext_ctrls_common()
3679 if (cs->count > ARRAY_SIZE(helper)) { in v4l2_g_ext_ctrls_common()
3680 helpers = kvmalloc_array(cs->count, sizeof(helper[0]), in v4l2_g_ext_ctrls_common()
3683 return -ENOMEM; in v4l2_g_ext_ctrls_common()
3687 cs->error_idx = cs->count; in v4l2_g_ext_ctrls_common()
3689 for (i = 0; !ret && i < cs->count; i++) in v4l2_g_ext_ctrls_common()
3690 if (helpers[i].ref->ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in v4l2_g_ext_ctrls_common()
3691 ret = -EACCES; in v4l2_g_ext_ctrls_common()
3693 for (i = 0; !ret && i < cs->count; i++) { in v4l2_g_ext_ctrls_common()
3703 master = helpers[i].mref->ctrl; in v4l2_g_ext_ctrls_common()
3704 cs->error_idx = i; in v4l2_g_ext_ctrls_common()
3710 ((master->flags & V4L2_CTRL_FLAG_VOLATILE) || in v4l2_g_ext_ctrls_common()
3711 (master->has_volatiles && !is_cur_manual(master)))) { in v4l2_g_ext_ctrls_common()
3712 for (j = 0; j < master->ncontrols; j++) in v4l2_g_ext_ctrls_common()
3713 cur_to_new(master->cluster[j]); in v4l2_g_ext_ctrls_common()
3717 /* If OK, then copy the current (for non-volatile controls) in v4l2_g_ext_ctrls_common()
3724 if (helpers[idx].ref->req) in v4l2_g_ext_ctrls_common()
3725 ret = req_to_user(cs->controls + idx, in v4l2_g_ext_ctrls_common()
3726 helpers[idx].ref->req); in v4l2_g_ext_ctrls_common()
3728 ret = ctrl_to_user(cs->controls + idx, in v4l2_g_ext_ctrls_common()
3729 helpers[idx].ref->ctrl); in v4l2_g_ext_ctrls_common()
3736 if (cs->count > ARRAY_SIZE(helper)) in v4l2_g_ext_ctrls_common()
3752 if (set && WARN_ON(req->state != MEDIA_REQUEST_STATE_UPDATING)) in v4l2_ctrls_find_req_obj()
3753 return ERR_PTR(-EBUSY); in v4l2_ctrls_find_req_obj()
3759 return ERR_PTR(-ENOENT); in v4l2_ctrls_find_req_obj()
3763 return ERR_PTR(-ENOMEM); in v4l2_ctrls_find_req_obj()
3765 obj = &new_hdl->req_obj; in v4l2_ctrls_find_req_obj()
3766 ret = v4l2_ctrl_handler_init(new_hdl, (hdl->nr_of_buckets - 1) * 8); in v4l2_ctrls_find_req_obj()
3786 if (cs->which == V4L2_CTRL_WHICH_REQUEST_VAL) { in v4l2_g_ext_ctrls()
3787 if (!mdev || cs->request_fd < 0) in v4l2_g_ext_ctrls()
3788 return -EINVAL; in v4l2_g_ext_ctrls()
3790 req = media_request_get_by_fd(mdev, cs->request_fd); in v4l2_g_ext_ctrls()
3794 if (req->state != MEDIA_REQUEST_STATE_COMPLETE) { in v4l2_g_ext_ctrls()
3796 return -EACCES; in v4l2_g_ext_ctrls()
3830 struct v4l2_ctrl *master = ctrl->cluster[0]; in get_ctrl()
3838 if (!ctrl->is_int && ctrl->type != V4L2_CTRL_TYPE_INTEGER64) in get_ctrl()
3839 return -EINVAL; in get_ctrl()
3841 if (ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) in get_ctrl()
3842 return -EACCES; in get_ctrl()
3846 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in get_ctrl()
3847 for (i = 0; i < master->ncontrols; i++) in get_ctrl()
3848 cur_to_new(master->cluster[i]); in get_ctrl()
3860 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_g_ctrl()
3864 if (ctrl == NULL || !ctrl->is_int) in v4l2_g_ctrl()
3865 return -EINVAL; in v4l2_g_ctrl()
3867 control->value = c.value; in v4l2_g_ctrl()
3877 if (WARN_ON(!ctrl->is_int)) in v4l2_ctrl_g_ctrl()
3890 if (WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64)) in v4l2_ctrl_g_ctrl_int64()
3901 Must be called with ctrl->handler->lock held. */
3913 for (i = 0; i < master->ncontrols; i++) { in try_or_set_cluster()
3914 struct v4l2_ctrl *ctrl = master->cluster[i]; in try_or_set_cluster()
3919 if (!ctrl->is_new) { in try_or_set_cluster()
3925 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) in try_or_set_cluster()
3926 return -EBUSY; in try_or_set_cluster()
3941 for (i = 0; i < master->ncontrols; i++) { in try_or_set_cluster()
3943 * If we switch from auto to manual mode, and this cluster in try_or_set_cluster()
3944 * contains volatile controls, then all non-master controls in try_or_set_cluster()
3950 master->has_volatiles && master->cluster[i]) in try_or_set_cluster()
3951 master->cluster[i]->has_changed = true; in try_or_set_cluster()
3953 new_to_cur(fh, master->cluster[i], ch_flags | in try_or_set_cluster()
3968 cs->error_idx = cs->count; in validate_ctrls()
3969 for (i = 0; i < cs->count; i++) { in validate_ctrls()
3970 struct v4l2_ctrl *ctrl = helpers[i].ref->ctrl; in validate_ctrls()
3973 cs->error_idx = i; in validate_ctrls()
3975 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) { in validate_ctrls()
3977 "control id 0x%x is read-only\n", in validate_ctrls()
3978 ctrl->id); in validate_ctrls()
3979 return -EACCES; in validate_ctrls()
3983 but it makes sense to do an up-front check as well. Once in validate_ctrls()
3986 best-effort to avoid that. */ in validate_ctrls()
3987 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) { in validate_ctrls()
3990 ctrl->id); in validate_ctrls()
3991 return -EBUSY; in validate_ctrls()
3997 if (ctrl->is_ptr) in validate_ctrls()
3999 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in validate_ctrls()
4000 p_new.p_s64 = &cs->controls[i].value64; in validate_ctrls()
4002 p_new.p_s32 = &cs->controls[i].value; in validate_ctrls()
4016 for (i = 1; i < master->ncontrols; i++) in update_from_auto_cluster()
4017 cur_to_new(master->cluster[i]); in update_from_auto_cluster()
4019 for (i = 1; i < master->ncontrols; i++) in update_from_auto_cluster()
4020 if (master->cluster[i]) in update_from_auto_cluster()
4021 master->cluster[i]->is_new = 1; in update_from_auto_cluster()
4024 /* Try or try-and-set controls */
4035 cs->error_idx = cs->count; in try_set_ext_ctrls_common()
4038 if (cs->which == V4L2_CTRL_WHICH_DEF_VAL) { in try_set_ext_ctrls_common()
4041 return -EINVAL; in try_set_ext_ctrls_common()
4044 cs->which = V4L2_CTRL_ID2WHICH(cs->which); in try_set_ext_ctrls_common()
4049 return -EINVAL; in try_set_ext_ctrls_common()
4052 if (cs->count == 0) in try_set_ext_ctrls_common()
4053 return class_check(hdl, cs->which); in try_set_ext_ctrls_common()
4055 if (cs->count > ARRAY_SIZE(helper)) { in try_set_ext_ctrls_common()
4056 helpers = kvmalloc_array(cs->count, sizeof(helper[0]), in try_set_ext_ctrls_common()
4059 return -ENOMEM; in try_set_ext_ctrls_common()
4065 cs->error_idx = cs->count; in try_set_ext_ctrls_common()
4066 for (i = 0; !ret && i < cs->count; i++) { in try_set_ext_ctrls_common()
4073 cs->error_idx = i; in try_set_ext_ctrls_common()
4074 master = helpers[i].mref->ctrl; in try_set_ext_ctrls_common()
4078 for (j = 0; j < master->ncontrols; j++) in try_set_ext_ctrls_common()
4079 if (master->cluster[j]) in try_set_ext_ctrls_common()
4080 master->cluster[j]->is_new = 0; in try_set_ext_ctrls_common()
4082 /* For volatile autoclusters that are currently in auto mode in try_set_ext_ctrls_common()
4083 we need to discover if it will be set to manual mode. in try_set_ext_ctrls_common()
4088 if (master->is_auto && master->has_volatiles && in try_set_ext_ctrls_common()
4090 /* Pick an initial non-manual value */ in try_set_ext_ctrls_common()
4091 s32 new_auto_val = master->manual_mode_value + 1; in try_set_ext_ctrls_common()
4097 if (helpers[tmp_idx].ref->ctrl == master) in try_set_ext_ctrls_common()
4098 new_auto_val = cs->controls[tmp_idx].value; in try_set_ext_ctrls_common()
4103 if (new_auto_val == master->manual_mode_value) in try_set_ext_ctrls_common()
4107 /* Copy the new caller-supplied control values. in try_set_ext_ctrls_common()
4110 struct v4l2_ctrl *ctrl = helpers[idx].ref->ctrl; in try_set_ext_ctrls_common()
4112 ret = user_to_new(cs->controls + idx, ctrl); in try_set_ext_ctrls_common()
4113 if (!ret && ctrl->is_ptr) in try_set_ext_ctrls_common()
4114 ret = validate_new(ctrl, ctrl->p_new); in try_set_ext_ctrls_common()
4120 !hdl->req_obj.req && set, 0); in try_set_ext_ctrls_common()
4121 if (!ret && hdl->req_obj.req && set) { in try_set_ext_ctrls_common()
4122 for (j = 0; j < master->ncontrols; j++) { in try_set_ext_ctrls_common()
4124 find_ref(hdl, master->cluster[j]->id); in try_set_ext_ctrls_common()
4134 ret = new_to_user(cs->controls + idx, in try_set_ext_ctrls_common()
4135 helpers[idx].ref->ctrl); in try_set_ext_ctrls_common()
4142 if (cs->count > ARRAY_SIZE(helper)) in try_set_ext_ctrls_common()
4157 if (cs->which == V4L2_CTRL_WHICH_REQUEST_VAL) { in try_set_ext_ctrls()
4161 return -EINVAL; in try_set_ext_ctrls()
4164 if (cs->request_fd < 0) { in try_set_ext_ctrls()
4166 video_device_node_name(vdev), cs->request_fd); in try_set_ext_ctrls()
4167 return -EINVAL; in try_set_ext_ctrls()
4170 req = media_request_get_by_fd(mdev, cs->request_fd); in try_set_ext_ctrls()
4173 video_device_node_name(vdev), cs->request_fd); in try_set_ext_ctrls()
4180 video_device_node_name(vdev), cs->request_fd); in try_set_ext_ctrls()
4190 cs->request_fd); in try_set_ext_ctrls()
4236 struct v4l2_ctrl *master = ctrl->cluster[0]; in set_ctrl()
4241 for (i = 0; i < master->ncontrols; i++) in set_ctrl()
4242 if (master->cluster[i]) in set_ctrl()
4243 master->cluster[i]->is_new = 0; in set_ctrl()
4245 ret = validate_new(ctrl, ctrl->p_new); in set_ctrl()
4250 manual mode we have to update the current volatile values since in set_ctrl()
4252 if (master->is_auto && master->has_volatiles && ctrl == master && in set_ctrl()
4253 !is_cur_manual(master) && ctrl->val == master->manual_mode_value) in set_ctrl()
4256 ctrl->is_new = 1; in set_ctrl()
4278 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(hdl, control->id); in v4l2_s_ctrl()
4279 struct v4l2_ext_control c = { control->id }; in v4l2_s_ctrl()
4282 if (ctrl == NULL || !ctrl->is_int) in v4l2_s_ctrl()
4283 return -EINVAL; in v4l2_s_ctrl()
4285 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) in v4l2_s_ctrl()
4286 return -EACCES; in v4l2_s_ctrl()
4288 c.value = control->value; in v4l2_s_ctrl()
4290 control->value = c.value; in v4l2_s_ctrl()
4297 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl()
4300 if (WARN_ON(!ctrl->is_int)) in __v4l2_ctrl_s_ctrl()
4301 return -EINVAL; in __v4l2_ctrl_s_ctrl()
4302 ctrl->val = val; in __v4l2_ctrl_s_ctrl()
4309 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_int64()
4312 if (WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64)) in __v4l2_ctrl_s_ctrl_int64()
4313 return -EINVAL; in __v4l2_ctrl_s_ctrl_int64()
4314 *ctrl->p_new.p_s64 = val; in __v4l2_ctrl_s_ctrl_int64()
4321 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_string()
4324 if (WARN_ON(ctrl->type != V4L2_CTRL_TYPE_STRING)) in __v4l2_ctrl_s_ctrl_string()
4325 return -EINVAL; in __v4l2_ctrl_s_ctrl_string()
4326 strscpy(ctrl->p_new.p_char, s, ctrl->maximum + 1); in __v4l2_ctrl_s_ctrl_string()
4334 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_s_ctrl_compound()
4337 if (WARN_ON(ctrl->type != type)) in __v4l2_ctrl_s_ctrl_compound()
4338 return -EINVAL; in __v4l2_ctrl_s_ctrl_compound()
4339 memcpy(ctrl->p_new.p, p, ctrl->elems * ctrl->elem_size); in __v4l2_ctrl_s_ctrl_compound()
4364 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_request_complete()
4365 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_complete()
4366 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_request_complete()
4369 if (ctrl->flags & V4L2_CTRL_FLAG_VOLATILE) { in v4l2_ctrl_request_complete()
4370 ref->req = ref; in v4l2_ctrl_request_complete()
4374 for (i = 0; i < master->ncontrols; i++) in v4l2_ctrl_request_complete()
4375 cur_to_new(master->cluster[i]); in v4l2_ctrl_request_complete()
4381 if (ref->req == ref) in v4l2_ctrl_request_complete()
4385 if (ref->req) { in v4l2_ctrl_request_complete()
4386 ptr_to_ptr(ctrl, ref->req->p_req, ref->p_req); in v4l2_ctrl_request_complete()
4388 ptr_to_ptr(ctrl, ctrl->p_cur, ref->p_req); in v4l2_ctrl_request_complete()
4390 * Set ref->req to ensure that when userspace wants to in v4l2_ctrl_request_complete()
4394 ref->req = ref; in v4l2_ctrl_request_complete()
4399 mutex_lock(main_hdl->lock); in v4l2_ctrl_request_complete()
4400 WARN_ON(!hdl->request_is_queued); in v4l2_ctrl_request_complete()
4401 list_del_init(&hdl->requests_queued); in v4l2_ctrl_request_complete()
4402 hdl->request_is_queued = false; in v4l2_ctrl_request_complete()
4403 mutex_unlock(main_hdl->lock); in v4l2_ctrl_request_complete()
4420 if (WARN_ON(req->state != MEDIA_REQUEST_STATE_QUEUED)) in v4l2_ctrl_request_setup()
4421 return -EBUSY; in v4l2_ctrl_request_setup()
4431 if (obj->completed) { in v4l2_ctrl_request_setup()
4433 return -EBUSY; in v4l2_ctrl_request_setup()
4437 list_for_each_entry(ref, &hdl->ctrl_refs, node) in v4l2_ctrl_request_setup()
4438 ref->req_done = false; in v4l2_ctrl_request_setup()
4440 list_for_each_entry(ref, &hdl->ctrl_refs, node) { in v4l2_ctrl_request_setup()
4441 struct v4l2_ctrl *ctrl = ref->ctrl; in v4l2_ctrl_request_setup()
4442 struct v4l2_ctrl *master = ctrl->cluster[0]; in v4l2_ctrl_request_setup()
4448 * Skip button controls and read-only controls. in v4l2_ctrl_request_setup()
4450 if (ref->req_done || ctrl->type == V4L2_CTRL_TYPE_BUTTON || in v4l2_ctrl_request_setup()
4451 (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) in v4l2_ctrl_request_setup()
4455 for (i = 0; i < master->ncontrols; i++) { in v4l2_ctrl_request_setup()
4456 if (master->cluster[i]) { in v4l2_ctrl_request_setup()
4458 find_ref(hdl, master->cluster[i]->id); in v4l2_ctrl_request_setup()
4460 if (r->req && r == r->req) { in v4l2_ctrl_request_setup()
4471 for (i = 0; i < master->ncontrols; i++) { in v4l2_ctrl_request_setup()
4472 if (master->cluster[i]) { in v4l2_ctrl_request_setup()
4474 find_ref(hdl, master->cluster[i]->id); in v4l2_ctrl_request_setup()
4477 master->cluster[i]->is_new = 1; in v4l2_ctrl_request_setup()
4478 r->req_done = true; in v4l2_ctrl_request_setup()
4482 * For volatile autoclusters that are currently in auto mode in v4l2_ctrl_request_setup()
4483 * we need to discover if it will be set to manual mode. in v4l2_ctrl_request_setup()
4489 if (master->is_auto && master->has_volatiles && in v4l2_ctrl_request_setup()
4491 s32 new_auto_val = *master->p_new.p_s32; in v4l2_ctrl_request_setup()
4497 if (new_auto_val == master->manual_mode_value) in v4l2_ctrl_request_setup()
4518 ctrl->call_notify = 0; in v4l2_ctrl_notify()
4521 if (WARN_ON(ctrl->handler->notify && ctrl->handler->notify != notify)) in v4l2_ctrl_notify()
4523 ctrl->handler->notify = notify; in v4l2_ctrl_notify()
4524 ctrl->handler->notify_priv = priv; in v4l2_ctrl_notify()
4525 ctrl->call_notify = 1; in v4l2_ctrl_notify()
4536 lockdep_assert_held(ctrl->handler->lock); in __v4l2_ctrl_modify_range()
4538 switch (ctrl->type) { in __v4l2_ctrl_modify_range()
4548 if (ctrl->is_array) in __v4l2_ctrl_modify_range()
4549 return -EINVAL; in __v4l2_ctrl_modify_range()
4550 ret = check_range(ctrl->type, min, max, step, def); in __v4l2_ctrl_modify_range()
4555 return -EINVAL; in __v4l2_ctrl_modify_range()
4557 if ((ctrl->minimum != min) || (ctrl->maximum != max) || in __v4l2_ctrl_modify_range()
4558 (ctrl->step != step) || ctrl->default_value != def) { in __v4l2_ctrl_modify_range()
4560 ctrl->minimum = min; in __v4l2_ctrl_modify_range()
4561 ctrl->maximum = max; in __v4l2_ctrl_modify_range()
4562 ctrl->step = step; in __v4l2_ctrl_modify_range()
4563 ctrl->default_value = def; in __v4l2_ctrl_modify_range()
4566 if (validate_new(ctrl, ctrl->p_new)) { in __v4l2_ctrl_modify_range()
4567 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
4568 *ctrl->p_new.p_s64 = def; in __v4l2_ctrl_modify_range()
4570 *ctrl->p_new.p_s32 = def; in __v4l2_ctrl_modify_range()
4573 if (ctrl->type == V4L2_CTRL_TYPE_INTEGER64) in __v4l2_ctrl_modify_range()
4574 value_changed = *ctrl->p_new.p_s64 != *ctrl->p_cur.p_s64; in __v4l2_ctrl_modify_range()
4576 value_changed = *ctrl->p_new.p_s32 != *ctrl->p_cur.p_s32; in __v4l2_ctrl_modify_range()
4587 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_add_event()
4590 return -EINVAL; in v4l2_ctrl_add_event()
4593 list_add_tail(&sev->node, &ctrl->ev_subs); in v4l2_ctrl_add_event()
4594 if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && in v4l2_ctrl_add_event()
4595 (sev->flags & V4L2_EVENT_SUB_FL_SEND_INITIAL)) { in v4l2_ctrl_add_event()
4599 if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)) in v4l2_ctrl_add_event()
4604 sev->elems = elems; in v4l2_ctrl_add_event()
4605 v4l2_event_queue_fh(sev->fh, &ev); in v4l2_ctrl_add_event()
4613 struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); in v4l2_ctrl_del_event()
4619 list_del(&sev->node); in v4l2_ctrl_del_event()
4625 u32 old_changes = old->u.ctrl.changes; in v4l2_ctrl_replace()
4627 old->u.ctrl = new->u.ctrl; in v4l2_ctrl_replace()
4628 old->u.ctrl.changes |= old_changes; in v4l2_ctrl_replace()
4634 new->u.ctrl.changes |= old->u.ctrl.changes; in v4l2_ctrl_merge()
4649 struct v4l2_fh *vfh = file->private_data; in v4l2_ctrl_log_status()
4651 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) && vfd->v4l2_dev) in v4l2_ctrl_log_status()
4652 v4l2_ctrl_handler_log_status(vfh->ctrl_handler, in v4l2_ctrl_log_status()
4653 vfd->v4l2_dev->name); in v4l2_ctrl_log_status()
4661 if (sub->type == V4L2_EVENT_CTRL) in v4l2_ctrl_subscribe_event()
4663 return -EINVAL; in v4l2_ctrl_subscribe_event()
4670 if (!sd->ctrl_handler) in v4l2_ctrl_subdev_subscribe_event()
4671 return -EINVAL; in v4l2_ctrl_subdev_subscribe_event()
4678 struct v4l2_fh *fh = file->private_data; in v4l2_ctrl_poll()
4680 poll_wait(file, &fh->wait, wait); in v4l2_ctrl_poll()
4691 if (p->orientation != V4L2_FWNODE_PROPERTY_UNSET) { in v4l2_ctrl_new_fwnode_properties()
4694 switch (p->orientation) { in v4l2_ctrl_new_fwnode_properties()
4705 return -EINVAL; in v4l2_ctrl_new_fwnode_properties()
4711 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
4714 if (p->rotation != V4L2_FWNODE_PROPERTY_UNSET) { in v4l2_ctrl_new_fwnode_properties()
4717 p->rotation, p->rotation, 1, in v4l2_ctrl_new_fwnode_properties()
4718 p->rotation)) in v4l2_ctrl_new_fwnode_properties()
4719 return hdl->error; in v4l2_ctrl_new_fwnode_properties()
4722 return hdl->error; in v4l2_ctrl_new_fwnode_properties()