Lines Matching refs:mapping

384 static int uvc_mapping_get_menu_value(const struct uvc_control_mapping *mapping,  in uvc_mapping_get_menu_value()  argument
387 if (!test_bit(idx, &mapping->menu_mask)) in uvc_mapping_get_menu_value()
390 if (mapping->menu_mapping) in uvc_mapping_get_menu_value()
391 return mapping->menu_mapping[idx]; in uvc_mapping_get_menu_value()
397 uvc_mapping_get_menu_name(const struct uvc_control_mapping *mapping, u32 idx) in uvc_mapping_get_menu_name() argument
399 if (!test_bit(idx, &mapping->menu_mask)) in uvc_mapping_get_menu_name()
402 if (mapping->menu_names) in uvc_mapping_get_menu_name()
403 return mapping->menu_names[idx]; in uvc_mapping_get_menu_name()
405 return v4l2_ctrl_get_menu(mapping->id)[idx]; in uvc_mapping_get_menu_name()
408 static s32 uvc_ctrl_get_zoom(struct uvc_control_mapping *mapping, in uvc_ctrl_get_zoom() argument
426 static void uvc_ctrl_set_zoom(struct uvc_control_mapping *mapping, in uvc_ctrl_set_zoom() argument
433 static s32 uvc_ctrl_get_rel_speed(struct uvc_control_mapping *mapping, in uvc_ctrl_get_rel_speed() argument
436 unsigned int first = mapping->offset / 8; in uvc_ctrl_get_rel_speed()
453 static void uvc_ctrl_set_rel_speed(struct uvc_control_mapping *mapping, in uvc_ctrl_set_rel_speed() argument
456 unsigned int first = mapping->offset / 8; in uvc_ctrl_set_rel_speed()
871 static s32 uvc_get_le_value(struct uvc_control_mapping *mapping, in uvc_get_le_value() argument
874 int bits = mapping->size; in uvc_get_le_value()
875 int offset = mapping->offset; in uvc_get_le_value()
896 if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED) in uvc_get_le_value()
897 value |= -(value & (1 << (mapping->size - 1))); in uvc_get_le_value()
906 static void uvc_set_le_value(struct uvc_control_mapping *mapping, in uvc_set_le_value() argument
909 int bits = mapping->size; in uvc_set_le_value()
910 int offset = mapping->offset; in uvc_set_le_value()
919 if (mapping->v4l2_type == V4L2_CTRL_TYPE_BUTTON) in uvc_set_le_value()
949 struct uvc_control_mapping **mapping, struct uvc_control **control, in __uvc_find_control() argument
967 *mapping = map; in __uvc_find_control()
971 if ((*mapping == NULL || (*mapping)->id > map->id) && in __uvc_find_control()
974 *mapping = map; in __uvc_find_control()
981 u32 v4l2_id, struct uvc_control_mapping **mapping) in uvc_find_control() argument
987 *mapping = NULL; in uvc_find_control()
994 __uvc_find_control(entity, v4l2_id, mapping, &ctrl, next); in uvc_find_control()
1063 static s32 __uvc_ctrl_get_value(struct uvc_control_mapping *mapping, in __uvc_ctrl_get_value() argument
1066 s32 value = mapping->get(mapping, UVC_GET_CUR, data); in __uvc_ctrl_get_value()
1068 if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { in __uvc_ctrl_get_value()
1071 for (i = 0; BIT(i) <= mapping->menu_mask; ++i) { in __uvc_ctrl_get_value()
1074 if (!test_bit(i, &mapping->menu_mask)) in __uvc_ctrl_get_value()
1077 menu_value = uvc_mapping_get_menu_value(mapping, i); in __uvc_ctrl_get_value()
1127 struct uvc_control_mapping *mapping, in __uvc_ctrl_get() argument
1139 *value = __uvc_ctrl_get_value(mapping, in __uvc_ctrl_get()
1204 struct uvc_control_mapping *mapping; in uvc_ctrl_is_accessible() local
1214 ctrl = uvc_find_control(chain, v4l2_id, &mapping); in uvc_ctrl_is_accessible()
1224 if (ioctl != VIDIOC_S_EXT_CTRLS || !mapping->master_id) in uvc_ctrl_is_accessible()
1232 if (ctrls->controls[i].id == mapping->master_id) in uvc_ctrl_is_accessible()
1234 mapping->master_manual ? 0 : -EACCES; in uvc_ctrl_is_accessible()
1237 __uvc_find_control(ctrl->entity, mapping->master_id, &master_map, in uvc_ctrl_is_accessible()
1244 if (ret >= 0 && val != mapping->master_manual) in uvc_ctrl_is_accessible()
1265 struct uvc_control_mapping *mapping) in uvc_get_ctrl_bitmap() argument
1273 return mapping->get(mapping, UVC_GET_RES, in uvc_get_ctrl_bitmap()
1277 return mapping->get(mapping, UVC_GET_MAX, in uvc_get_ctrl_bitmap()
1285 struct uvc_control_mapping *mapping, in __uvc_query_v4l2_ctrl() argument
1293 v4l2_ctrl->id = mapping->id; in __uvc_query_v4l2_ctrl()
1294 v4l2_ctrl->type = mapping->v4l2_type; in __uvc_query_v4l2_ctrl()
1295 strscpy(v4l2_ctrl->name, uvc_map_get_name(mapping), in __uvc_query_v4l2_ctrl()
1304 if (mapping->master_id) in __uvc_query_v4l2_ctrl()
1305 __uvc_find_control(ctrl->entity, mapping->master_id, in __uvc_query_v4l2_ctrl()
1313 if (val != mapping->master_manual) in __uvc_query_v4l2_ctrl()
1324 v4l2_ctrl->default_value = mapping->get(mapping, UVC_GET_DEF, in __uvc_query_v4l2_ctrl()
1328 switch (mapping->v4l2_type) { in __uvc_query_v4l2_ctrl()
1330 v4l2_ctrl->minimum = ffs(mapping->menu_mask) - 1; in __uvc_query_v4l2_ctrl()
1331 v4l2_ctrl->maximum = fls(mapping->menu_mask) - 1; in __uvc_query_v4l2_ctrl()
1334 for (i = 0; BIT(i) <= mapping->menu_mask; ++i) { in __uvc_query_v4l2_ctrl()
1337 if (!test_bit(i, &mapping->menu_mask)) in __uvc_query_v4l2_ctrl()
1340 menu_value = uvc_mapping_get_menu_value(mapping, i); in __uvc_query_v4l2_ctrl()
1364 v4l2_ctrl->maximum = uvc_get_ctrl_bitmap(ctrl, mapping); in __uvc_query_v4l2_ctrl()
1373 v4l2_ctrl->minimum = mapping->get(mapping, UVC_GET_MIN, in __uvc_query_v4l2_ctrl()
1377 v4l2_ctrl->maximum = mapping->get(mapping, UVC_GET_MAX, in __uvc_query_v4l2_ctrl()
1381 v4l2_ctrl->step = mapping->get(mapping, UVC_GET_RES, in __uvc_query_v4l2_ctrl()
1391 struct uvc_control_mapping *mapping; in uvc_query_v4l2_ctrl() local
1405 ctrl = uvc_find_control(chain, v4l2_ctrl->id, &mapping); in uvc_query_v4l2_ctrl()
1417 ret = uvc_query_v4l2_class(chain, v4l2_ctrl->id, mapping->id, in uvc_query_v4l2_ctrl()
1423 ret = __uvc_query_v4l2_ctrl(chain, ctrl, mapping, v4l2_ctrl); in uvc_query_v4l2_ctrl()
1441 struct uvc_control_mapping *mapping; in uvc_query_v4l2_menu() local
1452 if (index >= BITS_PER_TYPE(mapping->menu_mask)) in uvc_query_v4l2_menu()
1459 ctrl = uvc_find_control(chain, query_menu->id, &mapping); in uvc_query_v4l2_menu()
1460 if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU) { in uvc_query_v4l2_menu()
1465 if (!test_bit(query_menu->index, &mapping->menu_mask)) { in uvc_query_v4l2_menu()
1470 if (mapping->data_type == UVC_CTRL_DATA_TYPE_BITMASK) { in uvc_query_v4l2_menu()
1479 mask = uvc_mapping_get_menu_value(mapping, query_menu->index); in uvc_query_v4l2_menu()
1485 if (!(uvc_get_ctrl_bitmap(ctrl, mapping) & mask)) { in uvc_query_v4l2_menu()
1491 name = uvc_mapping_get_menu_name(mapping, query_menu->index); in uvc_query_v4l2_menu()
1511 struct uvc_control_mapping *mapping, in uvc_ctrl_fill_event() argument
1516 __uvc_query_v4l2_ctrl(chain, ctrl, mapping, &v4l2_ctrl); in uvc_ctrl_fill_event()
1540 struct uvc_control_mapping *mapping, s32 value, u32 changes) in uvc_ctrl_send_event() argument
1546 if (list_empty(&mapping->ev_subs)) in uvc_ctrl_send_event()
1549 uvc_ctrl_fill_event(chain, &ev, ctrl, mapping, value, changes); in uvc_ctrl_send_event()
1551 list_for_each_entry(sev, &mapping->ev_subs, node) { in uvc_ctrl_send_event()
1567 struct uvc_control_mapping *mapping = NULL; in uvc_ctrl_send_slave_event() local
1572 __uvc_find_control(master->entity, slave_id, &mapping, &ctrl, 0); in uvc_ctrl_send_slave_event()
1576 if (__uvc_ctrl_get(chain, ctrl, mapping, &val) == 0) in uvc_ctrl_send_slave_event()
1579 uvc_ctrl_send_event(chain, handle, ctrl, mapping, val, changes); in uvc_ctrl_send_slave_event()
1585 struct uvc_control_mapping *mapping; in uvc_ctrl_status_event() local
1594 list_for_each_entry(mapping, &ctrl->info.mappings, list) { in uvc_ctrl_status_event()
1595 s32 value = __uvc_ctrl_get_value(mapping, data); in uvc_ctrl_status_event()
1601 for (i = 0; i < ARRAY_SIZE(mapping->slave_ids); ++i) { in uvc_ctrl_status_event()
1602 if (!mapping->slave_ids[i]) in uvc_ctrl_status_event()
1606 mapping->slave_ids[i]); in uvc_ctrl_status_event()
1609 uvc_ctrl_send_event(chain, handle, ctrl, mapping, value, in uvc_ctrl_status_event()
1674 struct uvc_control_mapping *mapping; in uvc_ctrl_send_events() local
1681 ctrl = uvc_find_control(handle->chain, xctrls[i].id, &mapping); in uvc_ctrl_send_events()
1687 for (j = 0; j < ARRAY_SIZE(mapping->slave_ids); ++j) { in uvc_ctrl_send_events()
1688 u32 slave_id = mapping->slave_ids[j]; in uvc_ctrl_send_events()
1709 if (mapping->master_id && in uvc_ctrl_send_events()
1711 mapping->master_id)) in uvc_ctrl_send_events()
1714 uvc_ctrl_send_event(handle->chain, handle, ctrl, mapping, in uvc_ctrl_send_events()
1722 struct uvc_control_mapping *mapping; in uvc_ctrl_add_event() local
1735 ctrl = uvc_find_control(handle->chain, sev->id, &mapping); in uvc_ctrl_add_event()
1741 list_add_tail(&sev->node, &mapping->ev_subs); in uvc_ctrl_add_event()
1747 if (__uvc_ctrl_get(handle->chain, ctrl, mapping, &val) == 0) in uvc_ctrl_add_event()
1750 uvc_ctrl_fill_event(handle->chain, &ev, ctrl, mapping, val, in uvc_ctrl_add_event()
1871 struct uvc_control_mapping *mapping = NULL; in uvc_ctrl_find_ctrl_idx() local
1879 __uvc_find_control(entity, ctrls->controls[i].id, &mapping, in uvc_ctrl_find_ctrl_idx()
1920 struct uvc_control_mapping *mapping; in uvc_ctrl_get() local
1925 ctrl = uvc_find_control(chain, xctrl->id, &mapping); in uvc_ctrl_get()
1929 return __uvc_ctrl_get(chain, ctrl, mapping, &xctrl->value); in uvc_ctrl_get()
1937 struct uvc_control_mapping *mapping; in uvc_ctrl_set() local
1947 ctrl = uvc_find_control(chain, xctrl->id, &mapping); in uvc_ctrl_set()
1954 switch (mapping->v4l2_type) { in uvc_ctrl_set()
1962 min = mapping->get(mapping, UVC_GET_MIN, in uvc_ctrl_set()
1964 max = mapping->get(mapping, UVC_GET_MAX, in uvc_ctrl_set()
1966 step = mapping->get(mapping, UVC_GET_RES, in uvc_ctrl_set()
1973 if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED) in uvc_ctrl_set()
1987 xctrl->value &= uvc_get_ctrl_bitmap(ctrl, mapping); in uvc_ctrl_set()
1997 if (xctrl->value < (ffs(mapping->menu_mask) - 1) || in uvc_ctrl_set()
1998 xctrl->value > (fls(mapping->menu_mask) - 1)) in uvc_ctrl_set()
2001 if (!test_bit(xctrl->value, &mapping->menu_mask)) in uvc_ctrl_set()
2004 value = uvc_mapping_get_menu_value(mapping, xctrl->value); in uvc_ctrl_set()
2010 if (mapping->data_type == UVC_CTRL_DATA_TYPE_BITMASK) { in uvc_ctrl_set()
2017 if (!(uvc_get_ctrl_bitmap(ctrl, mapping) & value)) in uvc_ctrl_set()
2033 if ((ctrl->info.size * 8) != mapping->size) { in uvc_ctrl_set()
2046 mapping->set(mapping, value, in uvc_ctrl_set()
2420 struct uvc_control *ctrl, const struct uvc_control_mapping *mapping) in __uvc_ctrl_add_mapping() argument
2431 map = kmemdup(mapping, sizeof(*mapping), GFP_KERNEL); in __uvc_ctrl_add_mapping()
2440 if (mapping->name) { in __uvc_ctrl_add_mapping()
2441 map->name = kstrdup(mapping->name, GFP_KERNEL); in __uvc_ctrl_add_mapping()
2448 if (mapping->menu_mapping && mapping->menu_mask) { in __uvc_ctrl_add_mapping()
2449 size = sizeof(mapping->menu_mapping[0]) in __uvc_ctrl_add_mapping()
2450 * fls(mapping->menu_mask); in __uvc_ctrl_add_mapping()
2451 map->menu_mapping = kmemdup(mapping->menu_mapping, size, in __uvc_ctrl_add_mapping()
2456 if (mapping->menu_names && mapping->menu_mask) { in __uvc_ctrl_add_mapping()
2457 size = sizeof(mapping->menu_names[0]) in __uvc_ctrl_add_mapping()
2458 * fls(mapping->menu_mask); in __uvc_ctrl_add_mapping()
2459 map->menu_names = kmemdup(mapping->menu_names, size, in __uvc_ctrl_add_mapping()
2494 const struct uvc_control_mapping *mapping) in uvc_ctrl_add_mapping() argument
2503 if (mapping->id & ~V4L2_CTRL_ID_MASK) { in uvc_ctrl_add_mapping()
2506 uvc_map_get_name(mapping), mapping->id); in uvc_ctrl_add_mapping()
2515 !uvc_entity_match_guid(entity, mapping->entity)) in uvc_ctrl_add_mapping()
2520 if (ctrl->index == mapping->selector - 1) { in uvc_ctrl_add_mapping()
2543 if (mapping->size > 32 || in uvc_ctrl_add_mapping()
2544 mapping->offset + mapping->size > ctrl->info.size * 8) { in uvc_ctrl_add_mapping()
2550 if (mapping->id == map->id) { in uvc_ctrl_add_mapping()
2553 uvc_map_get_name(mapping), mapping->id); in uvc_ctrl_add_mapping()
2564 uvc_map_get_name(mapping), UVC_MAX_CONTROL_MAPPINGS); in uvc_ctrl_add_mapping()
2569 ret = __uvc_ctrl_add_mapping(chain, ctrl, mapping); in uvc_ctrl_add_mapping()
2681 const struct uvc_control_mapping *mapping = &uvc_ctrl_mappings[i]; in uvc_ctrl_init_ctrl() local
2683 if (!uvc_entity_match_guid(ctrl->entity, mapping->entity) || in uvc_ctrl_init_ctrl()
2684 ctrl->info.selector != mapping->selector) in uvc_ctrl_init_ctrl()
2688 if (mapping->filter_mapping) { in uvc_ctrl_init_ctrl()
2689 mapping = mapping->filter_mapping(chain, ctrl); in uvc_ctrl_init_ctrl()
2690 if (!mapping) in uvc_ctrl_init_ctrl()
2694 __uvc_ctrl_add_mapping(chain, ctrl, mapping); in uvc_ctrl_init_ctrl()
2779 struct uvc_control_mapping *mapping, *nm; in uvc_ctrl_cleanup_mappings() local
2781 list_for_each_entry_safe(mapping, nm, &ctrl->info.mappings, list) { in uvc_ctrl_cleanup_mappings()
2782 list_del(&mapping->list); in uvc_ctrl_cleanup_mappings()
2783 kfree(mapping->menu_names); in uvc_ctrl_cleanup_mappings()
2784 kfree(mapping->menu_mapping); in uvc_ctrl_cleanup_mappings()
2785 kfree(mapping->name); in uvc_ctrl_cleanup_mappings()
2786 kfree(mapping); in uvc_ctrl_cleanup_mappings()