4 * Configfs support for the uvc function.
6 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * http://www.samsung.com
9 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include "uvc_configfs.h"
18 #define UVCG_STREAMING_CONTROL_SIZE 1
20 #define UVC_ATTR(prefix, cname, aname) \
21 static struct configfs_attribute prefix##attr_##cname = { \
22 .ca_name = __stringify(aname), \
23 .ca_mode = S_IRUGO | S_IWUGO, \
24 .ca_owner = THIS_MODULE, \
25 .show = prefix##cname##_show, \
26 .store = prefix##cname##_store, \
29 #define UVC_ATTR_RO(prefix, cname, aname) \
30 static struct configfs_attribute prefix##attr_##cname = { \
31 .ca_name = __stringify(aname), \
33 .ca_owner = THIS_MODULE, \
34 .show = prefix##cname##_show, \
37 static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item);
39 /* control/header/<NAME> */
40 DECLARE_UVC_HEADER_DESCRIPTOR(1);
42 struct uvcg_control_header {
43 struct config_item item;
44 struct UVC_HEADER_DESCRIPTOR(1) desc;
48 static struct uvcg_control_header *to_uvcg_control_header(struct config_item *item)
50 return container_of(item, struct uvcg_control_header, item);
53 #define UVCG_CTRL_HDR_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit) \
54 static ssize_t uvcg_control_header_##cname##_show( \
55 struct config_item *item, char *page) \
57 struct uvcg_control_header *ch = to_uvcg_control_header(item); \
58 struct f_uvc_opts *opts; \
59 struct config_item *opts_item; \
60 struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\
63 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
65 opts_item = ch->item.ci_parent->ci_parent->ci_parent; \
66 opts = to_f_uvc_opts(opts_item); \
68 mutex_lock(&opts->lock); \
69 result = sprintf(page, "%d\n", conv(ch->desc.aname)); \
70 mutex_unlock(&opts->lock); \
72 mutex_unlock(su_mutex); \
77 uvcg_control_header_##cname##_store(struct config_item *item, \
78 const char *page, size_t len) \
80 struct uvcg_control_header *ch = to_uvcg_control_header(item); \
81 struct f_uvc_opts *opts; \
82 struct config_item *opts_item; \
83 struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\
87 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
89 opts_item = ch->item.ci_parent->ci_parent->ci_parent; \
90 opts = to_f_uvc_opts(opts_item); \
92 mutex_lock(&opts->lock); \
93 if (ch->linked || opts->refcnt) { \
98 ret = str2u(page, 0, &num); \
106 ch->desc.aname = vnoc(num); \
109 mutex_unlock(&opts->lock); \
110 mutex_unlock(su_mutex); \
114 UVC_ATTR(uvcg_control_header_, cname, aname)
116 UVCG_CTRL_HDR_ATTR(bcd_uvc, bcdUVC, le16_to_cpu, kstrtou16, u16, cpu_to_le16,
119 UVCG_CTRL_HDR_ATTR(dw_clock_frequency, dwClockFrequency, le32_to_cpu, kstrtou32,
120 u32, cpu_to_le32, 0x7fffffff);
122 #undef UVCG_CTRL_HDR_ATTR
124 static struct configfs_attribute *uvcg_control_header_attrs[] = {
125 &uvcg_control_header_attr_bcd_uvc,
126 &uvcg_control_header_attr_dw_clock_frequency,
130 static struct config_item_type uvcg_control_header_type = {
131 .ct_attrs = uvcg_control_header_attrs,
132 .ct_owner = THIS_MODULE,
135 static struct config_item *uvcg_control_header_make(struct config_group *group,
138 struct uvcg_control_header *h;
140 h = kzalloc(sizeof(*h), GFP_KERNEL);
142 return ERR_PTR(-ENOMEM);
144 h->desc.bLength = UVC_DT_HEADER_SIZE(1);
145 h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
146 h->desc.bDescriptorSubType = UVC_VC_HEADER;
147 h->desc.bcdUVC = cpu_to_le16(0x0100);
148 h->desc.dwClockFrequency = cpu_to_le32(48000000);
150 config_item_init_type_name(&h->item, name, &uvcg_control_header_type);
155 static void uvcg_control_header_drop(struct config_group *group,
156 struct config_item *item)
158 struct uvcg_control_header *h = to_uvcg_control_header(item);
164 static struct uvcg_control_header_grp {
165 struct config_group group;
166 } uvcg_control_header_grp;
168 static struct configfs_group_operations uvcg_control_header_grp_ops = {
169 .make_item = uvcg_control_header_make,
170 .drop_item = uvcg_control_header_drop,
173 static struct config_item_type uvcg_control_header_grp_type = {
174 .ct_group_ops = &uvcg_control_header_grp_ops,
175 .ct_owner = THIS_MODULE,
178 /* control/processing/default */
179 static struct uvcg_default_processing {
180 struct config_group group;
181 } uvcg_default_processing;
183 static inline struct uvcg_default_processing
184 *to_uvcg_default_processing(struct config_item *item)
186 return container_of(to_config_group(item),
187 struct uvcg_default_processing, group);
190 #define UVCG_DEFAULT_PROCESSING_ATTR(cname, aname, conv) \
191 static ssize_t uvcg_default_processing_##cname##_show( \
192 struct config_item *item, char *page) \
194 struct uvcg_default_processing *dp = to_uvcg_default_processing(item); \
195 struct f_uvc_opts *opts; \
196 struct config_item *opts_item; \
197 struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex; \
198 struct uvc_processing_unit_descriptor *pd; \
201 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
203 opts_item = dp->group.cg_item.ci_parent->ci_parent->ci_parent; \
204 opts = to_f_uvc_opts(opts_item); \
205 pd = &opts->uvc_processing; \
207 mutex_lock(&opts->lock); \
208 result = sprintf(page, "%d\n", conv(pd->aname)); \
209 mutex_unlock(&opts->lock); \
211 mutex_unlock(su_mutex); \
215 UVC_ATTR_RO(uvcg_default_processing_, cname, aname)
217 #define identity_conv(x) (x)
219 UVCG_DEFAULT_PROCESSING_ATTR(b_unit_id, bUnitID, identity_conv);
220 UVCG_DEFAULT_PROCESSING_ATTR(b_source_id, bSourceID, identity_conv);
221 UVCG_DEFAULT_PROCESSING_ATTR(w_max_multiplier, wMaxMultiplier, le16_to_cpu);
222 UVCG_DEFAULT_PROCESSING_ATTR(i_processing, iProcessing, identity_conv);
226 #undef UVCG_DEFAULT_PROCESSING_ATTR
228 static ssize_t uvcg_default_processing_bm_controls_show(
229 struct config_item *item, char *page)
231 struct uvcg_default_processing *dp = to_uvcg_default_processing(item);
232 struct f_uvc_opts *opts;
233 struct config_item *opts_item;
234 struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex;
235 struct uvc_processing_unit_descriptor *pd;
239 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
241 opts_item = dp->group.cg_item.ci_parent->ci_parent->ci_parent;
242 opts = to_f_uvc_opts(opts_item);
243 pd = &opts->uvc_processing;
245 mutex_lock(&opts->lock);
246 for (result = 0, i = 0; i < pd->bControlSize; ++i) {
247 result += sprintf(pg, "%d\n", pd->bmControls[i]);
250 mutex_unlock(&opts->lock);
252 mutex_unlock(su_mutex);
257 UVC_ATTR_RO(uvcg_default_processing_, bm_controls, bmControls);
259 static struct configfs_attribute *uvcg_default_processing_attrs[] = {
260 &uvcg_default_processing_attr_b_unit_id,
261 &uvcg_default_processing_attr_b_source_id,
262 &uvcg_default_processing_attr_w_max_multiplier,
263 &uvcg_default_processing_attr_bm_controls,
264 &uvcg_default_processing_attr_i_processing,
268 static struct config_item_type uvcg_default_processing_type = {
269 .ct_attrs = uvcg_default_processing_attrs,
270 .ct_owner = THIS_MODULE,
273 /* struct uvcg_processing {}; */
275 static struct config_group *uvcg_processing_default_groups[] = {
276 &uvcg_default_processing.group,
280 /* control/processing */
281 static struct uvcg_processing_grp {
282 struct config_group group;
283 } uvcg_processing_grp;
285 static struct config_item_type uvcg_processing_grp_type = {
286 .ct_owner = THIS_MODULE,
289 /* control/terminal/camera/default */
290 static struct uvcg_default_camera {
291 struct config_group group;
292 } uvcg_default_camera;
294 static inline struct uvcg_default_camera
295 *to_uvcg_default_camera(struct config_item *item)
297 return container_of(to_config_group(item),
298 struct uvcg_default_camera, group);
301 #define UVCG_DEFAULT_CAMERA_ATTR(cname, aname, conv) \
302 static ssize_t uvcg_default_camera_##cname##_show( \
303 struct config_item *item, char *page) \
305 struct uvcg_default_camera *dc = to_uvcg_default_camera(item); \
306 struct f_uvc_opts *opts; \
307 struct config_item *opts_item; \
308 struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \
309 struct uvc_camera_terminal_descriptor *cd; \
312 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
314 opts_item = dc->group.cg_item.ci_parent->ci_parent->ci_parent-> \
316 opts = to_f_uvc_opts(opts_item); \
317 cd = &opts->uvc_camera_terminal; \
319 mutex_lock(&opts->lock); \
320 result = sprintf(page, "%d\n", conv(cd->aname)); \
321 mutex_unlock(&opts->lock); \
323 mutex_unlock(su_mutex); \
328 UVC_ATTR_RO(uvcg_default_camera_, cname, aname)
330 #define identity_conv(x) (x)
332 UVCG_DEFAULT_CAMERA_ATTR(b_terminal_id, bTerminalID, identity_conv);
333 UVCG_DEFAULT_CAMERA_ATTR(w_terminal_type, wTerminalType, le16_to_cpu);
334 UVCG_DEFAULT_CAMERA_ATTR(b_assoc_terminal, bAssocTerminal, identity_conv);
335 UVCG_DEFAULT_CAMERA_ATTR(i_terminal, iTerminal, identity_conv);
336 UVCG_DEFAULT_CAMERA_ATTR(w_objective_focal_length_min, wObjectiveFocalLengthMin,
338 UVCG_DEFAULT_CAMERA_ATTR(w_objective_focal_length_max, wObjectiveFocalLengthMax,
340 UVCG_DEFAULT_CAMERA_ATTR(w_ocular_focal_length, wOcularFocalLength,
345 #undef UVCG_DEFAULT_CAMERA_ATTR
347 static ssize_t uvcg_default_camera_bm_controls_show(
348 struct config_item *item, char *page)
350 struct uvcg_default_camera *dc = to_uvcg_default_camera(item);
351 struct f_uvc_opts *opts;
352 struct config_item *opts_item;
353 struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex;
354 struct uvc_camera_terminal_descriptor *cd;
358 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
360 opts_item = dc->group.cg_item.ci_parent->ci_parent->ci_parent->
362 opts = to_f_uvc_opts(opts_item);
363 cd = &opts->uvc_camera_terminal;
365 mutex_lock(&opts->lock);
366 for (result = 0, i = 0; i < cd->bControlSize; ++i) {
367 result += sprintf(pg, "%d\n", cd->bmControls[i]);
370 mutex_unlock(&opts->lock);
372 mutex_unlock(su_mutex);
376 UVC_ATTR_RO(uvcg_default_camera_, bm_controls, bmControls);
378 static struct configfs_attribute *uvcg_default_camera_attrs[] = {
379 &uvcg_default_camera_attr_b_terminal_id,
380 &uvcg_default_camera_attr_w_terminal_type,
381 &uvcg_default_camera_attr_b_assoc_terminal,
382 &uvcg_default_camera_attr_i_terminal,
383 &uvcg_default_camera_attr_w_objective_focal_length_min,
384 &uvcg_default_camera_attr_w_objective_focal_length_max,
385 &uvcg_default_camera_attr_w_ocular_focal_length,
386 &uvcg_default_camera_attr_bm_controls,
390 static struct config_item_type uvcg_default_camera_type = {
391 .ct_attrs = uvcg_default_camera_attrs,
392 .ct_owner = THIS_MODULE,
395 /* struct uvcg_camera {}; */
397 static struct config_group *uvcg_camera_default_groups[] = {
398 &uvcg_default_camera.group,
402 /* control/terminal/camera */
403 static struct uvcg_camera_grp {
404 struct config_group group;
407 static struct config_item_type uvcg_camera_grp_type = {
408 .ct_owner = THIS_MODULE,
411 /* control/terminal/output/default */
412 static struct uvcg_default_output {
413 struct config_group group;
414 } uvcg_default_output;
416 static inline struct uvcg_default_output
417 *to_uvcg_default_output(struct config_item *item)
419 return container_of(to_config_group(item),
420 struct uvcg_default_output, group);
423 #define UVCG_DEFAULT_OUTPUT_ATTR(cname, aname, conv) \
424 static ssize_t uvcg_default_output_##cname##_show( \
425 struct config_item *item, char *page) \
427 struct uvcg_default_output *dout = to_uvcg_default_output(item); \
428 struct f_uvc_opts *opts; \
429 struct config_item *opts_item; \
430 struct mutex *su_mutex = &dout->group.cg_subsys->su_mutex; \
431 struct uvc_output_terminal_descriptor *cd; \
434 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
436 opts_item = dout->group.cg_item.ci_parent->ci_parent-> \
437 ci_parent->ci_parent; \
438 opts = to_f_uvc_opts(opts_item); \
439 cd = &opts->uvc_output_terminal; \
441 mutex_lock(&opts->lock); \
442 result = sprintf(page, "%d\n", conv(cd->aname)); \
443 mutex_unlock(&opts->lock); \
445 mutex_unlock(su_mutex); \
450 UVC_ATTR_RO(uvcg_default_output_, cname, aname)
452 #define identity_conv(x) (x)
454 UVCG_DEFAULT_OUTPUT_ATTR(b_terminal_id, bTerminalID, identity_conv);
455 UVCG_DEFAULT_OUTPUT_ATTR(w_terminal_type, wTerminalType, le16_to_cpu);
456 UVCG_DEFAULT_OUTPUT_ATTR(b_assoc_terminal, bAssocTerminal, identity_conv);
457 UVCG_DEFAULT_OUTPUT_ATTR(b_source_id, bSourceID, identity_conv);
458 UVCG_DEFAULT_OUTPUT_ATTR(i_terminal, iTerminal, identity_conv);
462 #undef UVCG_DEFAULT_OUTPUT_ATTR
464 static struct configfs_attribute *uvcg_default_output_attrs[] = {
465 &uvcg_default_output_attr_b_terminal_id,
466 &uvcg_default_output_attr_w_terminal_type,
467 &uvcg_default_output_attr_b_assoc_terminal,
468 &uvcg_default_output_attr_b_source_id,
469 &uvcg_default_output_attr_i_terminal,
473 static struct config_item_type uvcg_default_output_type = {
474 .ct_attrs = uvcg_default_output_attrs,
475 .ct_owner = THIS_MODULE,
478 /* struct uvcg_output {}; */
480 static struct config_group *uvcg_output_default_groups[] = {
481 &uvcg_default_output.group,
485 /* control/terminal/output */
486 static struct uvcg_output_grp {
487 struct config_group group;
490 static struct config_item_type uvcg_output_grp_type = {
491 .ct_owner = THIS_MODULE,
494 static struct config_group *uvcg_terminal_default_groups[] = {
495 &uvcg_camera_grp.group,
496 &uvcg_output_grp.group,
500 /* control/terminal */
501 static struct uvcg_terminal_grp {
502 struct config_group group;
505 static struct config_item_type uvcg_terminal_grp_type = {
506 .ct_owner = THIS_MODULE,
509 /* control/class/{fs} */
510 static struct uvcg_control_class {
511 struct config_group group;
512 } uvcg_control_class_fs, uvcg_control_class_ss;
515 static inline struct uvc_descriptor_header
516 **uvcg_get_ctl_class_arr(struct config_item *i, struct f_uvc_opts *o)
518 struct uvcg_control_class *cl = container_of(to_config_group(i),
519 struct uvcg_control_class, group);
521 if (cl == &uvcg_control_class_fs)
522 return o->uvc_fs_control_cls;
524 if (cl == &uvcg_control_class_ss)
525 return o->uvc_ss_control_cls;
530 static int uvcg_control_class_allow_link(struct config_item *src,
531 struct config_item *target)
533 struct config_item *control, *header;
534 struct f_uvc_opts *opts;
535 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
536 struct uvc_descriptor_header **class_array;
537 struct uvcg_control_header *target_hdr;
540 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
542 control = src->ci_parent->ci_parent;
543 header = config_group_find_item(to_config_group(control), "header");
544 if (!header || target->ci_parent != header)
547 opts = to_f_uvc_opts(control->ci_parent);
549 mutex_lock(&opts->lock);
551 class_array = uvcg_get_ctl_class_arr(src, opts);
554 if (opts->refcnt || class_array[0]) {
559 target_hdr = to_uvcg_control_header(target);
560 ++target_hdr->linked;
561 class_array[0] = (struct uvc_descriptor_header *)&target_hdr->desc;
565 mutex_unlock(&opts->lock);
567 config_item_put(header);
568 mutex_unlock(su_mutex);
572 static int uvcg_control_class_drop_link(struct config_item *src,
573 struct config_item *target)
575 struct config_item *control, *header;
576 struct f_uvc_opts *opts;
577 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
578 struct uvc_descriptor_header **class_array;
579 struct uvcg_control_header *target_hdr;
582 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
584 control = src->ci_parent->ci_parent;
585 header = config_group_find_item(to_config_group(control), "header");
586 if (!header || target->ci_parent != header)
589 opts = to_f_uvc_opts(control->ci_parent);
591 mutex_lock(&opts->lock);
593 class_array = uvcg_get_ctl_class_arr(src, opts);
601 target_hdr = to_uvcg_control_header(target);
602 --target_hdr->linked;
603 class_array[0] = NULL;
607 mutex_unlock(&opts->lock);
609 config_item_put(header);
610 mutex_unlock(su_mutex);
614 static struct configfs_item_operations uvcg_control_class_item_ops = {
615 .allow_link = uvcg_control_class_allow_link,
616 .drop_link = uvcg_control_class_drop_link,
619 static struct config_item_type uvcg_control_class_type = {
620 .ct_item_ops = &uvcg_control_class_item_ops,
621 .ct_owner = THIS_MODULE,
624 static struct config_group *uvcg_control_class_default_groups[] = {
625 &uvcg_control_class_fs.group,
626 &uvcg_control_class_ss.group,
631 static struct uvcg_control_class_grp {
632 struct config_group group;
633 } uvcg_control_class_grp;
635 static struct config_item_type uvcg_control_class_grp_type = {
636 .ct_owner = THIS_MODULE,
639 static struct config_group *uvcg_control_default_groups[] = {
640 &uvcg_control_header_grp.group,
641 &uvcg_processing_grp.group,
642 &uvcg_terminal_grp.group,
643 &uvcg_control_class_grp.group,
648 static struct uvcg_control_grp {
649 struct config_group group;
652 static struct config_item_type uvcg_control_grp_type = {
653 .ct_owner = THIS_MODULE,
656 /* streaming/uncompressed */
657 static struct uvcg_uncompressed_grp {
658 struct config_group group;
659 } uvcg_uncompressed_grp;
661 /* streaming/mjpeg */
662 static struct uvcg_mjpeg_grp {
663 struct config_group group;
666 static struct config_item *fmt_parent[] = {
667 &uvcg_uncompressed_grp.group.cg_item,
668 &uvcg_mjpeg_grp.group.cg_item,
671 enum uvcg_format_type {
672 UVCG_UNCOMPRESSED = 0,
677 struct config_group group;
678 enum uvcg_format_type type;
681 __u8 bmaControls[UVCG_STREAMING_CONTROL_SIZE];
684 static struct uvcg_format *to_uvcg_format(struct config_item *item)
686 return container_of(to_config_group(item), struct uvcg_format, group);
689 static ssize_t uvcg_format_bma_controls_show(struct uvcg_format *f, char *page)
691 struct f_uvc_opts *opts;
692 struct config_item *opts_item;
693 struct mutex *su_mutex = &f->group.cg_subsys->su_mutex;
697 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
699 opts_item = f->group.cg_item.ci_parent->ci_parent->ci_parent;
700 opts = to_f_uvc_opts(opts_item);
702 mutex_lock(&opts->lock);
703 result = sprintf(pg, "0x");
705 for (i = 0; i < UVCG_STREAMING_CONTROL_SIZE; ++i) {
706 result += sprintf(pg, "%x\n", f->bmaControls[i]);
709 mutex_unlock(&opts->lock);
711 mutex_unlock(su_mutex);
715 static ssize_t uvcg_format_bma_controls_store(struct uvcg_format *ch,
716 const char *page, size_t len)
718 struct f_uvc_opts *opts;
719 struct config_item *opts_item;
720 struct mutex *su_mutex = &ch->group.cg_subsys->su_mutex;
723 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
725 opts_item = ch->group.cg_item.ci_parent->ci_parent->ci_parent;
726 opts = to_f_uvc_opts(opts_item);
728 mutex_lock(&opts->lock);
729 if (ch->linked || opts->refcnt) {
734 if (len < 4 || *page != '0' ||
735 (*(page + 1) != 'x' && *(page + 1) != 'X'))
737 ret = hex2bin(ch->bmaControls, page + 2, 1);
742 mutex_unlock(&opts->lock);
743 mutex_unlock(su_mutex);
747 struct uvcg_format_ptr {
748 struct uvcg_format *fmt;
749 struct list_head entry;
752 /* streaming/header/<NAME> */
753 struct uvcg_streaming_header {
754 struct config_item item;
755 struct uvc_input_header_descriptor desc;
757 struct list_head formats;
761 static struct uvcg_streaming_header *to_uvcg_streaming_header(struct config_item *item)
763 return container_of(item, struct uvcg_streaming_header, item);
766 static int uvcg_streaming_header_allow_link(struct config_item *src,
767 struct config_item *target)
769 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
770 struct config_item *opts_item;
771 struct f_uvc_opts *opts;
772 struct uvcg_streaming_header *src_hdr;
773 struct uvcg_format *target_fmt = NULL;
774 struct uvcg_format_ptr *format_ptr;
775 int i, ret = -EINVAL;
777 src_hdr = to_uvcg_streaming_header(src);
778 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
780 opts_item = src->ci_parent->ci_parent->ci_parent;
781 opts = to_f_uvc_opts(opts_item);
783 mutex_lock(&opts->lock);
785 if (src_hdr->linked) {
790 for (i = 0; i < ARRAY_SIZE(fmt_parent); ++i)
791 if (target->ci_parent == fmt_parent[i])
793 if (i == ARRAY_SIZE(fmt_parent))
796 target_fmt = container_of(to_config_group(target), struct uvcg_format,
801 format_ptr = kzalloc(sizeof(*format_ptr), GFP_KERNEL);
807 format_ptr->fmt = target_fmt;
808 list_add_tail(&format_ptr->entry, &src_hdr->formats);
810 ++target_fmt->linked;
813 mutex_unlock(&opts->lock);
814 mutex_unlock(su_mutex);
818 static int uvcg_streaming_header_drop_link(struct config_item *src,
819 struct config_item *target)
821 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
822 struct config_item *opts_item;
823 struct f_uvc_opts *opts;
824 struct uvcg_streaming_header *src_hdr;
825 struct uvcg_format *target_fmt = NULL;
826 struct uvcg_format_ptr *format_ptr, *tmp;
829 src_hdr = to_uvcg_streaming_header(src);
830 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
832 opts_item = src->ci_parent->ci_parent->ci_parent;
833 opts = to_f_uvc_opts(opts_item);
835 mutex_lock(&opts->lock);
836 target_fmt = container_of(to_config_group(target), struct uvcg_format,
841 list_for_each_entry_safe(format_ptr, tmp, &src_hdr->formats, entry)
842 if (format_ptr->fmt == target_fmt) {
843 list_del(&format_ptr->entry);
849 --target_fmt->linked;
852 mutex_unlock(&opts->lock);
853 mutex_unlock(su_mutex);
858 static struct configfs_item_operations uvcg_streaming_header_item_ops = {
859 .allow_link = uvcg_streaming_header_allow_link,
860 .drop_link = uvcg_streaming_header_drop_link,
863 #define UVCG_STREAMING_HEADER_ATTR(cname, aname, conv) \
864 static ssize_t uvcg_streaming_header_##cname##_show( \
865 struct config_item *item, char *page) \
867 struct uvcg_streaming_header *sh = to_uvcg_streaming_header(item); \
868 struct f_uvc_opts *opts; \
869 struct config_item *opts_item; \
870 struct mutex *su_mutex = &sh->item.ci_group->cg_subsys->su_mutex;\
873 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
875 opts_item = sh->item.ci_parent->ci_parent->ci_parent; \
876 opts = to_f_uvc_opts(opts_item); \
878 mutex_lock(&opts->lock); \
879 result = sprintf(page, "%d\n", conv(sh->desc.aname)); \
880 mutex_unlock(&opts->lock); \
882 mutex_unlock(su_mutex); \
886 UVC_ATTR_RO(uvcg_streaming_header_, cname, aname)
888 #define identity_conv(x) (x)
890 UVCG_STREAMING_HEADER_ATTR(bm_info, bmInfo, identity_conv);
891 UVCG_STREAMING_HEADER_ATTR(b_terminal_link, bTerminalLink, identity_conv);
892 UVCG_STREAMING_HEADER_ATTR(b_still_capture_method, bStillCaptureMethod,
894 UVCG_STREAMING_HEADER_ATTR(b_trigger_support, bTriggerSupport, identity_conv);
895 UVCG_STREAMING_HEADER_ATTR(b_trigger_usage, bTriggerUsage, identity_conv);
899 #undef UVCG_STREAMING_HEADER_ATTR
901 static struct configfs_attribute *uvcg_streaming_header_attrs[] = {
902 &uvcg_streaming_header_attr_bm_info,
903 &uvcg_streaming_header_attr_b_terminal_link,
904 &uvcg_streaming_header_attr_b_still_capture_method,
905 &uvcg_streaming_header_attr_b_trigger_support,
906 &uvcg_streaming_header_attr_b_trigger_usage,
910 static struct config_item_type uvcg_streaming_header_type = {
911 .ct_item_ops = &uvcg_streaming_header_item_ops,
912 .ct_attrs = uvcg_streaming_header_attrs,
913 .ct_owner = THIS_MODULE,
916 static struct config_item
917 *uvcg_streaming_header_make(struct config_group *group, const char *name)
919 struct uvcg_streaming_header *h;
921 h = kzalloc(sizeof(*h), GFP_KERNEL);
923 return ERR_PTR(-ENOMEM);
925 INIT_LIST_HEAD(&h->formats);
926 h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
927 h->desc.bDescriptorSubType = UVC_VS_INPUT_HEADER;
928 h->desc.bTerminalLink = 3;
929 h->desc.bControlSize = UVCG_STREAMING_CONTROL_SIZE;
931 config_item_init_type_name(&h->item, name, &uvcg_streaming_header_type);
936 static void uvcg_streaming_header_drop(struct config_group *group,
937 struct config_item *item)
939 struct uvcg_streaming_header *h = to_uvcg_streaming_header(item);
944 /* streaming/header */
945 static struct uvcg_streaming_header_grp {
946 struct config_group group;
947 } uvcg_streaming_header_grp;
949 static struct configfs_group_operations uvcg_streaming_header_grp_ops = {
950 .make_item = uvcg_streaming_header_make,
951 .drop_item = uvcg_streaming_header_drop,
954 static struct config_item_type uvcg_streaming_header_grp_type = {
955 .ct_group_ops = &uvcg_streaming_header_grp_ops,
956 .ct_owner = THIS_MODULE,
959 /* streaming/<mode>/<format>/<NAME> */
963 u8 b_descriptor_type;
964 u8 b_descriptor_subtype;
971 u32 dw_max_video_frame_buffer_size;
972 u32 dw_default_frame_interval;
973 u8 b_frame_interval_type;
974 } __attribute__((packed)) frame;
975 u32 *dw_frame_interval;
976 enum uvcg_format_type fmt_type;
977 struct config_item item;
980 static struct uvcg_frame *to_uvcg_frame(struct config_item *item)
982 return container_of(item, struct uvcg_frame, item);
985 #define UVCG_FRAME_ATTR(cname, aname, to_cpu_endian, to_little_endian, bits) \
986 static ssize_t uvcg_frame_##cname##_show(struct config_item *item, char *page)\
988 struct uvcg_frame *f = to_uvcg_frame(item); \
989 struct f_uvc_opts *opts; \
990 struct config_item *opts_item; \
991 struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\
994 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
996 opts_item = f->item.ci_parent->ci_parent->ci_parent->ci_parent; \
997 opts = to_f_uvc_opts(opts_item); \
999 mutex_lock(&opts->lock); \
1000 result = sprintf(page, "%d\n", to_cpu_endian(f->frame.cname)); \
1001 mutex_unlock(&opts->lock); \
1003 mutex_unlock(su_mutex); \
1007 static ssize_t uvcg_frame_##cname##_store(struct config_item *item, \
1008 const char *page, size_t len)\
1010 struct uvcg_frame *f = to_uvcg_frame(item); \
1011 struct f_uvc_opts *opts; \
1012 struct config_item *opts_item; \
1013 struct uvcg_format *fmt; \
1014 struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\
1018 ret = kstrtou##bits(page, 0, &num); \
1022 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1024 opts_item = f->item.ci_parent->ci_parent->ci_parent->ci_parent; \
1025 opts = to_f_uvc_opts(opts_item); \
1026 fmt = to_uvcg_format(f->item.ci_parent); \
1028 mutex_lock(&opts->lock); \
1029 if (fmt->linked || opts->refcnt) { \
1034 f->frame.cname = to_little_endian(num); \
1037 mutex_unlock(&opts->lock); \
1038 mutex_unlock(su_mutex); \
1042 UVC_ATTR(uvcg_frame_, cname, aname);
1044 #define noop_conversion(x) (x)
1046 UVCG_FRAME_ATTR(bm_capabilities, bmCapabilities, noop_conversion,
1047 noop_conversion, 8);
1048 UVCG_FRAME_ATTR(w_width, wWidth, le16_to_cpu, cpu_to_le16, 16);
1049 UVCG_FRAME_ATTR(w_height, wHeight, le16_to_cpu, cpu_to_le16, 16);
1050 UVCG_FRAME_ATTR(dw_min_bit_rate, dwMinBitRate, le32_to_cpu, cpu_to_le32, 32);
1051 UVCG_FRAME_ATTR(dw_max_bit_rate, dwMaxBitRate, le32_to_cpu, cpu_to_le32, 32);
1052 UVCG_FRAME_ATTR(dw_max_video_frame_buffer_size, dwMaxVideoFrameBufferSize,
1053 le32_to_cpu, cpu_to_le32, 32);
1054 UVCG_FRAME_ATTR(dw_default_frame_interval, dwDefaultFrameInterval,
1055 le32_to_cpu, cpu_to_le32, 32);
1057 #undef noop_conversion
1059 #undef UVCG_FRAME_ATTR
1061 static ssize_t uvcg_frame_dw_frame_interval_show(struct config_item *item,
1064 struct uvcg_frame *frm = to_uvcg_frame(item);
1065 struct f_uvc_opts *opts;
1066 struct config_item *opts_item;
1067 struct mutex *su_mutex = &frm->item.ci_group->cg_subsys->su_mutex;
1071 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
1073 opts_item = frm->item.ci_parent->ci_parent->ci_parent->ci_parent;
1074 opts = to_f_uvc_opts(opts_item);
1076 mutex_lock(&opts->lock);
1077 for (result = 0, i = 0; i < frm->frame.b_frame_interval_type; ++i) {
1078 result += sprintf(pg, "%d\n",
1079 le32_to_cpu(frm->dw_frame_interval[i]));
1082 mutex_unlock(&opts->lock);
1084 mutex_unlock(su_mutex);
1088 static inline int __uvcg_count_frm_intrv(char *buf, void *priv)
1094 static inline int __uvcg_fill_frm_intrv(char *buf, void *priv)
1099 ret = kstrtou32(buf, 0, &num);
1104 **interv = cpu_to_le32(num);
1110 static int __uvcg_iter_frm_intrv(const char *page, size_t len,
1111 int (*fun)(char *, void *), void *priv)
1113 /* sign, base 2 representation, newline, terminator */
1114 char buf[1 + sizeof(u32) * 8 + 1 + 1];
1115 const char *pg = page;
1121 while (pg - page < len) {
1123 while (i < sizeof(buf) && (pg - page < len) &&
1124 *pg != '\0' && *pg != '\n')
1126 if (i == sizeof(buf))
1128 while ((pg - page < len) && (*pg == '\0' || *pg == '\n'))
1131 ret = fun(buf, priv);
1139 static ssize_t uvcg_frame_dw_frame_interval_store(struct config_item *item,
1140 const char *page, size_t len)
1142 struct uvcg_frame *ch = to_uvcg_frame(item);
1143 struct f_uvc_opts *opts;
1144 struct config_item *opts_item;
1145 struct uvcg_format *fmt;
1146 struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;
1148 u32 *frm_intrv, *tmp;
1150 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
1152 opts_item = ch->item.ci_parent->ci_parent->ci_parent->ci_parent;
1153 opts = to_f_uvc_opts(opts_item);
1154 fmt = to_uvcg_format(ch->item.ci_parent);
1156 mutex_lock(&opts->lock);
1157 if (fmt->linked || opts->refcnt) {
1162 ret = __uvcg_iter_frm_intrv(page, len, __uvcg_count_frm_intrv, &n);
1166 tmp = frm_intrv = kcalloc(n, sizeof(u32), GFP_KERNEL);
1172 ret = __uvcg_iter_frm_intrv(page, len, __uvcg_fill_frm_intrv, &tmp);
1178 kfree(ch->dw_frame_interval);
1179 ch->dw_frame_interval = frm_intrv;
1180 ch->frame.b_frame_interval_type = n;
1184 mutex_unlock(&opts->lock);
1185 mutex_unlock(su_mutex);
1189 UVC_ATTR(uvcg_frame_, dw_frame_interval, dwFrameInterval);
1191 static struct configfs_attribute *uvcg_frame_attrs[] = {
1192 &uvcg_frame_attr_bm_capabilities,
1193 &uvcg_frame_attr_w_width,
1194 &uvcg_frame_attr_w_height,
1195 &uvcg_frame_attr_dw_min_bit_rate,
1196 &uvcg_frame_attr_dw_max_bit_rate,
1197 &uvcg_frame_attr_dw_max_video_frame_buffer_size,
1198 &uvcg_frame_attr_dw_default_frame_interval,
1199 &uvcg_frame_attr_dw_frame_interval,
1203 static struct config_item_type uvcg_frame_type = {
1204 .ct_attrs = uvcg_frame_attrs,
1205 .ct_owner = THIS_MODULE,
1208 static struct config_item *uvcg_frame_make(struct config_group *group,
1211 struct uvcg_frame *h;
1212 struct uvcg_format *fmt;
1213 struct f_uvc_opts *opts;
1214 struct config_item *opts_item;
1216 h = kzalloc(sizeof(*h), GFP_KERNEL);
1218 return ERR_PTR(-ENOMEM);
1220 h->frame.b_descriptor_type = USB_DT_CS_INTERFACE;
1221 h->frame.b_frame_index = 1;
1222 h->frame.w_width = cpu_to_le16(640);
1223 h->frame.w_height = cpu_to_le16(360);
1224 h->frame.dw_min_bit_rate = cpu_to_le32(18432000);
1225 h->frame.dw_max_bit_rate = cpu_to_le32(55296000);
1226 h->frame.dw_max_video_frame_buffer_size = cpu_to_le32(460800);
1227 h->frame.dw_default_frame_interval = cpu_to_le32(666666);
1229 opts_item = group->cg_item.ci_parent->ci_parent->ci_parent;
1230 opts = to_f_uvc_opts(opts_item);
1232 mutex_lock(&opts->lock);
1233 fmt = to_uvcg_format(&group->cg_item);
1234 if (fmt->type == UVCG_UNCOMPRESSED) {
1235 h->frame.b_descriptor_subtype = UVC_VS_FRAME_UNCOMPRESSED;
1236 h->fmt_type = UVCG_UNCOMPRESSED;
1237 } else if (fmt->type == UVCG_MJPEG) {
1238 h->frame.b_descriptor_subtype = UVC_VS_FRAME_MJPEG;
1239 h->fmt_type = UVCG_MJPEG;
1241 mutex_unlock(&opts->lock);
1243 return ERR_PTR(-EINVAL);
1246 mutex_unlock(&opts->lock);
1248 config_item_init_type_name(&h->item, name, &uvcg_frame_type);
1253 static void uvcg_frame_drop(struct config_group *group, struct config_item *item)
1255 struct uvcg_frame *h = to_uvcg_frame(item);
1256 struct uvcg_format *fmt;
1257 struct f_uvc_opts *opts;
1258 struct config_item *opts_item;
1260 opts_item = group->cg_item.ci_parent->ci_parent->ci_parent;
1261 opts = to_f_uvc_opts(opts_item);
1263 mutex_lock(&opts->lock);
1264 fmt = to_uvcg_format(&group->cg_item);
1267 mutex_unlock(&opts->lock);
1270 /* streaming/uncompressed/<NAME> */
1271 struct uvcg_uncompressed {
1272 struct uvcg_format fmt;
1273 struct uvc_format_uncompressed desc;
1276 static struct uvcg_uncompressed *to_uvcg_uncompressed(struct config_item *item)
1278 return container_of(
1279 container_of(to_config_group(item), struct uvcg_format, group),
1280 struct uvcg_uncompressed, fmt);
1283 static struct configfs_group_operations uvcg_uncompressed_group_ops = {
1284 .make_item = uvcg_frame_make,
1285 .drop_item = uvcg_frame_drop,
1288 static ssize_t uvcg_uncompressed_guid_format_show(struct config_item *item,
1291 struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item);
1292 struct f_uvc_opts *opts;
1293 struct config_item *opts_item;
1294 struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex;
1296 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
1298 opts_item = ch->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;
1299 opts = to_f_uvc_opts(opts_item);
1301 mutex_lock(&opts->lock);
1302 memcpy(page, ch->desc.guidFormat, sizeof(ch->desc.guidFormat));
1303 mutex_unlock(&opts->lock);
1305 mutex_unlock(su_mutex);
1307 return sizeof(ch->desc.guidFormat);
1310 static ssize_t uvcg_uncompressed_guid_format_store(struct config_item *item,
1311 const char *page, size_t len)
1313 struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item);
1314 struct f_uvc_opts *opts;
1315 struct config_item *opts_item;
1316 struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex;
1319 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
1321 opts_item = ch->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;
1322 opts = to_f_uvc_opts(opts_item);
1324 mutex_lock(&opts->lock);
1325 if (ch->fmt.linked || opts->refcnt) {
1330 memcpy(ch->desc.guidFormat, page,
1331 min(sizeof(ch->desc.guidFormat), len));
1332 ret = sizeof(ch->desc.guidFormat);
1335 mutex_unlock(&opts->lock);
1336 mutex_unlock(su_mutex);
1340 UVC_ATTR(uvcg_uncompressed_, guid_format, guidFormat);
1342 #define UVCG_UNCOMPRESSED_ATTR_RO(cname, aname, conv) \
1343 static ssize_t uvcg_uncompressed_##cname##_show( \
1344 struct config_item *item, char *page) \
1346 struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
1347 struct f_uvc_opts *opts; \
1348 struct config_item *opts_item; \
1349 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1352 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1354 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1355 opts = to_f_uvc_opts(opts_item); \
1357 mutex_lock(&opts->lock); \
1358 result = sprintf(page, "%d\n", conv(u->desc.aname)); \
1359 mutex_unlock(&opts->lock); \
1361 mutex_unlock(su_mutex); \
1365 UVC_ATTR_RO(uvcg_uncompressed_, cname, aname);
1367 #define UVCG_UNCOMPRESSED_ATTR(cname, aname, conv) \
1368 static ssize_t uvcg_uncompressed_##cname##_show( \
1369 struct config_item *item, char *page) \
1371 struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
1372 struct f_uvc_opts *opts; \
1373 struct config_item *opts_item; \
1374 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1377 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1379 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1380 opts = to_f_uvc_opts(opts_item); \
1382 mutex_lock(&opts->lock); \
1383 result = sprintf(page, "%d\n", conv(u->desc.aname)); \
1384 mutex_unlock(&opts->lock); \
1386 mutex_unlock(su_mutex); \
1391 uvcg_uncompressed_##cname##_store(struct config_item *item, \
1392 const char *page, size_t len) \
1394 struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
1395 struct f_uvc_opts *opts; \
1396 struct config_item *opts_item; \
1397 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1401 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1403 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1404 opts = to_f_uvc_opts(opts_item); \
1406 mutex_lock(&opts->lock); \
1407 if (u->fmt.linked || opts->refcnt) { \
1412 ret = kstrtou8(page, 0, &num); \
1420 u->desc.aname = num; \
1423 mutex_unlock(&opts->lock); \
1424 mutex_unlock(su_mutex); \
1428 UVC_ATTR(uvcg_uncompressed_, cname, aname);
1430 #define identity_conv(x) (x)
1432 UVCG_UNCOMPRESSED_ATTR(b_bits_per_pixel, bBitsPerPixel, identity_conv);
1433 UVCG_UNCOMPRESSED_ATTR(b_default_frame_index, bDefaultFrameIndex,
1435 UVCG_UNCOMPRESSED_ATTR_RO(b_aspect_ratio_x, bAspectRatioX, identity_conv);
1436 UVCG_UNCOMPRESSED_ATTR_RO(b_aspect_ratio_y, bAspectRatioY, identity_conv);
1437 UVCG_UNCOMPRESSED_ATTR_RO(bm_interface_flags, bmInterfaceFlags, identity_conv);
1439 #undef identity_conv
1441 #undef UVCG_UNCOMPRESSED_ATTR
1442 #undef UVCG_UNCOMPRESSED_ATTR_RO
1444 static inline ssize_t
1445 uvcg_uncompressed_bma_controls_show(struct config_item *item, char *page)
1447 struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item);
1448 return uvcg_format_bma_controls_show(&unc->fmt, page);
1451 static inline ssize_t
1452 uvcg_uncompressed_bma_controls_store(struct config_item *item,
1453 const char *page, size_t len)
1455 struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item);
1456 return uvcg_format_bma_controls_store(&unc->fmt, page, len);
1459 UVC_ATTR(uvcg_uncompressed_, bma_controls, bmaControls);
1461 static struct configfs_attribute *uvcg_uncompressed_attrs[] = {
1462 &uvcg_uncompressed_attr_guid_format,
1463 &uvcg_uncompressed_attr_b_bits_per_pixel,
1464 &uvcg_uncompressed_attr_b_default_frame_index,
1465 &uvcg_uncompressed_attr_b_aspect_ratio_x,
1466 &uvcg_uncompressed_attr_b_aspect_ratio_y,
1467 &uvcg_uncompressed_attr_bm_interface_flags,
1468 &uvcg_uncompressed_attr_bma_controls,
1472 static struct config_item_type uvcg_uncompressed_type = {
1473 .ct_group_ops = &uvcg_uncompressed_group_ops,
1474 .ct_attrs = uvcg_uncompressed_attrs,
1475 .ct_owner = THIS_MODULE,
1478 static struct config_group *uvcg_uncompressed_make(struct config_group *group,
1481 static char guid[] = {
1482 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00,
1483 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
1485 struct uvcg_uncompressed *h;
1487 h = kzalloc(sizeof(*h), GFP_KERNEL);
1489 return ERR_PTR(-ENOMEM);
1491 h->desc.bLength = UVC_DT_FORMAT_UNCOMPRESSED_SIZE;
1492 h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
1493 h->desc.bDescriptorSubType = UVC_VS_FORMAT_UNCOMPRESSED;
1494 memcpy(h->desc.guidFormat, guid, sizeof(guid));
1495 h->desc.bBitsPerPixel = 16;
1496 h->desc.bDefaultFrameIndex = 1;
1497 h->desc.bAspectRatioX = 0;
1498 h->desc.bAspectRatioY = 0;
1499 h->desc.bmInterfaceFlags = 0;
1500 h->desc.bCopyProtect = 0;
1502 h->fmt.type = UVCG_UNCOMPRESSED;
1503 config_group_init_type_name(&h->fmt.group, name,
1504 &uvcg_uncompressed_type);
1506 return &h->fmt.group;
1509 static void uvcg_uncompressed_drop(struct config_group *group,
1510 struct config_item *item)
1512 struct uvcg_uncompressed *h = to_uvcg_uncompressed(item);
1517 static struct configfs_group_operations uvcg_uncompressed_grp_ops = {
1518 .make_group = uvcg_uncompressed_make,
1519 .drop_item = uvcg_uncompressed_drop,
1522 static struct config_item_type uvcg_uncompressed_grp_type = {
1523 .ct_group_ops = &uvcg_uncompressed_grp_ops,
1524 .ct_owner = THIS_MODULE,
1527 /* streaming/mjpeg/<NAME> */
1529 struct uvcg_format fmt;
1530 struct uvc_format_mjpeg desc;
1533 static struct uvcg_mjpeg *to_uvcg_mjpeg(struct config_item *item)
1535 return container_of(
1536 container_of(to_config_group(item), struct uvcg_format, group),
1537 struct uvcg_mjpeg, fmt);
1540 static struct configfs_group_operations uvcg_mjpeg_group_ops = {
1541 .make_item = uvcg_frame_make,
1542 .drop_item = uvcg_frame_drop,
1545 #define UVCG_MJPEG_ATTR_RO(cname, aname, conv) \
1546 static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\
1548 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
1549 struct f_uvc_opts *opts; \
1550 struct config_item *opts_item; \
1551 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1554 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1556 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1557 opts = to_f_uvc_opts(opts_item); \
1559 mutex_lock(&opts->lock); \
1560 result = sprintf(page, "%d\n", conv(u->desc.aname)); \
1561 mutex_unlock(&opts->lock); \
1563 mutex_unlock(su_mutex); \
1567 UVC_ATTR_RO(uvcg_mjpeg_, cname, aname)
1569 #define UVCG_MJPEG_ATTR(cname, aname, conv) \
1570 static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\
1572 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
1573 struct f_uvc_opts *opts; \
1574 struct config_item *opts_item; \
1575 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1578 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1580 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1581 opts = to_f_uvc_opts(opts_item); \
1583 mutex_lock(&opts->lock); \
1584 result = sprintf(page, "%d\n", conv(u->desc.aname)); \
1585 mutex_unlock(&opts->lock); \
1587 mutex_unlock(su_mutex); \
1592 uvcg_mjpeg_##cname##_store(struct config_item *item, \
1593 const char *page, size_t len) \
1595 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
1596 struct f_uvc_opts *opts; \
1597 struct config_item *opts_item; \
1598 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1602 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1604 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1605 opts = to_f_uvc_opts(opts_item); \
1607 mutex_lock(&opts->lock); \
1608 if (u->fmt.linked || opts->refcnt) { \
1613 ret = kstrtou8(page, 0, &num); \
1621 u->desc.aname = num; \
1624 mutex_unlock(&opts->lock); \
1625 mutex_unlock(su_mutex); \
1629 UVC_ATTR(uvcg_mjpeg_, cname, aname)
1631 #define identity_conv(x) (x)
1633 UVCG_MJPEG_ATTR(b_default_frame_index, bDefaultFrameIndex,
1635 UVCG_MJPEG_ATTR_RO(bm_flags, bmFlags, identity_conv);
1636 UVCG_MJPEG_ATTR_RO(b_aspect_ratio_x, bAspectRatioX, identity_conv);
1637 UVCG_MJPEG_ATTR_RO(b_aspect_ratio_y, bAspectRatioY, identity_conv);
1638 UVCG_MJPEG_ATTR_RO(bm_interface_flags, bmInterfaceFlags, identity_conv);
1640 #undef identity_conv
1642 #undef UVCG_MJPEG_ATTR
1643 #undef UVCG_MJPEG_ATTR_RO
1645 static inline ssize_t
1646 uvcg_mjpeg_bma_controls_show(struct config_item *item, char *page)
1648 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item);
1649 return uvcg_format_bma_controls_show(&u->fmt, page);
1652 static inline ssize_t
1653 uvcg_mjpeg_bma_controls_store(struct config_item *item,
1654 const char *page, size_t len)
1656 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item);
1657 return uvcg_format_bma_controls_store(&u->fmt, page, len);
1660 UVC_ATTR(uvcg_mjpeg_, bma_controls, bmaControls);
1662 static struct configfs_attribute *uvcg_mjpeg_attrs[] = {
1663 &uvcg_mjpeg_attr_b_default_frame_index,
1664 &uvcg_mjpeg_attr_bm_flags,
1665 &uvcg_mjpeg_attr_b_aspect_ratio_x,
1666 &uvcg_mjpeg_attr_b_aspect_ratio_y,
1667 &uvcg_mjpeg_attr_bm_interface_flags,
1668 &uvcg_mjpeg_attr_bma_controls,
1672 static struct config_item_type uvcg_mjpeg_type = {
1673 .ct_group_ops = &uvcg_mjpeg_group_ops,
1674 .ct_attrs = uvcg_mjpeg_attrs,
1675 .ct_owner = THIS_MODULE,
1678 static struct config_group *uvcg_mjpeg_make(struct config_group *group,
1681 struct uvcg_mjpeg *h;
1683 h = kzalloc(sizeof(*h), GFP_KERNEL);
1685 return ERR_PTR(-ENOMEM);
1687 h->desc.bLength = UVC_DT_FORMAT_MJPEG_SIZE;
1688 h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
1689 h->desc.bDescriptorSubType = UVC_VS_FORMAT_MJPEG;
1690 h->desc.bDefaultFrameIndex = 1;
1691 h->desc.bAspectRatioX = 0;
1692 h->desc.bAspectRatioY = 0;
1693 h->desc.bmInterfaceFlags = 0;
1694 h->desc.bCopyProtect = 0;
1696 h->fmt.type = UVCG_MJPEG;
1697 config_group_init_type_name(&h->fmt.group, name,
1700 return &h->fmt.group;
1703 static void uvcg_mjpeg_drop(struct config_group *group,
1704 struct config_item *item)
1706 struct uvcg_mjpeg *h = to_uvcg_mjpeg(item);
1711 static struct configfs_group_operations uvcg_mjpeg_grp_ops = {
1712 .make_group = uvcg_mjpeg_make,
1713 .drop_item = uvcg_mjpeg_drop,
1716 static struct config_item_type uvcg_mjpeg_grp_type = {
1717 .ct_group_ops = &uvcg_mjpeg_grp_ops,
1718 .ct_owner = THIS_MODULE,
1721 /* streaming/color_matching/default */
1722 static struct uvcg_default_color_matching {
1723 struct config_group group;
1724 } uvcg_default_color_matching;
1726 static inline struct uvcg_default_color_matching
1727 *to_uvcg_default_color_matching(struct config_item *item)
1729 return container_of(to_config_group(item),
1730 struct uvcg_default_color_matching, group);
1733 #define UVCG_DEFAULT_COLOR_MATCHING_ATTR(cname, aname, conv) \
1734 static ssize_t uvcg_default_color_matching_##cname##_show( \
1735 struct config_item *item, char *page) \
1737 struct uvcg_default_color_matching *dc = \
1738 to_uvcg_default_color_matching(item); \
1739 struct f_uvc_opts *opts; \
1740 struct config_item *opts_item; \
1741 struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \
1742 struct uvc_color_matching_descriptor *cd; \
1745 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1747 opts_item = dc->group.cg_item.ci_parent->ci_parent->ci_parent; \
1748 opts = to_f_uvc_opts(opts_item); \
1749 cd = &opts->uvc_color_matching; \
1751 mutex_lock(&opts->lock); \
1752 result = sprintf(page, "%d\n", conv(cd->aname)); \
1753 mutex_unlock(&opts->lock); \
1755 mutex_unlock(su_mutex); \
1759 UVC_ATTR_RO(uvcg_default_color_matching_, cname, aname)
1761 #define identity_conv(x) (x)
1763 UVCG_DEFAULT_COLOR_MATCHING_ATTR(b_color_primaries, bColorPrimaries,
1765 UVCG_DEFAULT_COLOR_MATCHING_ATTR(b_transfer_characteristics,
1766 bTransferCharacteristics, identity_conv);
1767 UVCG_DEFAULT_COLOR_MATCHING_ATTR(b_matrix_coefficients, bMatrixCoefficients,
1770 #undef identity_conv
1772 #undef UVCG_DEFAULT_COLOR_MATCHING_ATTR
1774 static struct configfs_attribute *uvcg_default_color_matching_attrs[] = {
1775 &uvcg_default_color_matching_attr_b_color_primaries,
1776 &uvcg_default_color_matching_attr_b_transfer_characteristics,
1777 &uvcg_default_color_matching_attr_b_matrix_coefficients,
1781 static struct config_item_type uvcg_default_color_matching_type = {
1782 .ct_attrs = uvcg_default_color_matching_attrs,
1783 .ct_owner = THIS_MODULE,
1786 /* struct uvcg_color_matching {}; */
1788 static struct config_group *uvcg_color_matching_default_groups[] = {
1789 &uvcg_default_color_matching.group,
1793 /* streaming/color_matching */
1794 static struct uvcg_color_matching_grp {
1795 struct config_group group;
1796 } uvcg_color_matching_grp;
1798 static struct config_item_type uvcg_color_matching_grp_type = {
1799 .ct_owner = THIS_MODULE,
1802 /* streaming/class/{fs|hs|ss} */
1803 static struct uvcg_streaming_class {
1804 struct config_group group;
1805 } uvcg_streaming_class_fs, uvcg_streaming_class_hs, uvcg_streaming_class_ss;
1808 static inline struct uvc_descriptor_header
1809 ***__uvcg_get_stream_class_arr(struct config_item *i, struct f_uvc_opts *o)
1811 struct uvcg_streaming_class *cl = container_of(to_config_group(i),
1812 struct uvcg_streaming_class, group);
1814 if (cl == &uvcg_streaming_class_fs)
1815 return &o->uvc_fs_streaming_cls;
1817 if (cl == &uvcg_streaming_class_hs)
1818 return &o->uvc_hs_streaming_cls;
1820 if (cl == &uvcg_streaming_class_ss)
1821 return &o->uvc_ss_streaming_cls;
1826 enum uvcg_strm_type {
1833 * Iterate over a hierarchy of streaming descriptors' config items.
1834 * The items are created by the user with configfs.
1836 * It "processes" the header pointed to by @priv1, then for each format
1837 * that follows the header "processes" the format itself and then for
1838 * each frame inside a format "processes" the frame.
1840 * As a "processing" function the @fun is used.
1842 * __uvcg_iter_strm_cls() is used in two context: first, to calculate
1843 * the amount of memory needed for an array of streaming descriptors
1844 * and second, to actually fill the array.
1846 * @h: streaming header pointer
1847 * @priv2: an "inout" parameter (the caller might want to see the changes to it)
1848 * @priv3: an "inout" parameter (the caller might want to see the changes to it)
1849 * @fun: callback function for processing each level of the hierarchy
1851 static int __uvcg_iter_strm_cls(struct uvcg_streaming_header *h,
1852 void *priv2, void *priv3,
1853 int (*fun)(void *, void *, void *, int, enum uvcg_strm_type type))
1855 struct uvcg_format_ptr *f;
1856 struct config_group *grp;
1857 struct config_item *item;
1858 struct uvcg_frame *frm;
1865 ret = fun(h, priv2, priv3, 0, UVCG_HEADER);
1868 list_for_each_entry(f, &h->formats, entry) {
1869 ret = fun(f->fmt, priv2, priv3, i++, UVCG_FORMAT);
1872 grp = &f->fmt->group;
1873 list_for_each_entry(item, &grp->cg_children, ci_entry) {
1874 frm = to_uvcg_frame(item);
1875 ret = fun(frm, priv2, priv3, j++, UVCG_FRAME);
1885 * Count how many bytes are needed for an array of streaming descriptors.
1887 * @priv1: pointer to a header, format or frame
1888 * @priv2: inout parameter, accumulated size of the array
1889 * @priv3: inout parameter, accumulated number of the array elements
1890 * @n: unused, this function's prototype must match @fun in __uvcg_iter_strm_cls
1892 static int __uvcg_cnt_strm(void *priv1, void *priv2, void *priv3, int n,
1893 enum uvcg_strm_type type)
1895 size_t *size = priv2;
1896 size_t *count = priv3;
1900 struct uvcg_streaming_header *h = priv1;
1902 *size += sizeof(h->desc);
1904 *size += h->num_fmt * UVCG_STREAMING_CONTROL_SIZE;
1908 struct uvcg_format *fmt = priv1;
1910 if (fmt->type == UVCG_UNCOMPRESSED) {
1911 struct uvcg_uncompressed *u =
1912 container_of(fmt, struct uvcg_uncompressed,
1915 *size += sizeof(u->desc);
1916 } else if (fmt->type == UVCG_MJPEG) {
1917 struct uvcg_mjpeg *m =
1918 container_of(fmt, struct uvcg_mjpeg, fmt);
1920 *size += sizeof(m->desc);
1927 struct uvcg_frame *frm = priv1;
1928 int sz = sizeof(frm->dw_frame_interval);
1930 *size += sizeof(frm->frame);
1931 *size += frm->frame.b_frame_interval_type * sz;
1942 * Fill an array of streaming descriptors.
1944 * @priv1: pointer to a header, format or frame
1945 * @priv2: inout parameter, pointer into a block of memory
1946 * @priv3: inout parameter, pointer to a 2-dimensional array
1948 static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n,
1949 enum uvcg_strm_type type)
1951 void **dest = priv2;
1952 struct uvc_descriptor_header ***array = priv3;
1960 struct uvc_input_header_descriptor *ihdr = *dest;
1961 struct uvcg_streaming_header *h = priv1;
1962 struct uvcg_format_ptr *f;
1964 memcpy(*dest, &h->desc, sizeof(h->desc));
1965 *dest += sizeof(h->desc);
1966 sz = UVCG_STREAMING_CONTROL_SIZE;
1967 list_for_each_entry(f, &h->formats, entry) {
1968 memcpy(*dest, f->fmt->bmaControls, sz);
1971 ihdr->bLength = sizeof(h->desc) + h->num_fmt * sz;
1972 ihdr->bNumFormats = h->num_fmt;
1976 struct uvcg_format *fmt = priv1;
1978 if (fmt->type == UVCG_UNCOMPRESSED) {
1979 struct uvc_format_uncompressed *unc = *dest;
1980 struct uvcg_uncompressed *u =
1981 container_of(fmt, struct uvcg_uncompressed,
1984 memcpy(*dest, &u->desc, sizeof(u->desc));
1985 *dest += sizeof(u->desc);
1986 unc->bNumFrameDescriptors = fmt->num_frames;
1987 unc->bFormatIndex = n + 1;
1988 } else if (fmt->type == UVCG_MJPEG) {
1989 struct uvc_format_mjpeg *mjp = *dest;
1990 struct uvcg_mjpeg *m =
1991 container_of(fmt, struct uvcg_mjpeg, fmt);
1993 memcpy(*dest, &m->desc, sizeof(m->desc));
1994 *dest += sizeof(m->desc);
1995 mjp->bNumFrameDescriptors = fmt->num_frames;
1996 mjp->bFormatIndex = n + 1;
2003 struct uvcg_frame *frm = priv1;
2004 struct uvc_descriptor_header *h = *dest;
2006 sz = sizeof(frm->frame);
2007 memcpy(*dest, &frm->frame, sz);
2009 sz = frm->frame.b_frame_interval_type *
2010 sizeof(*frm->dw_frame_interval);
2011 memcpy(*dest, frm->dw_frame_interval, sz);
2013 if (frm->fmt_type == UVCG_UNCOMPRESSED)
2014 h->bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE(
2015 frm->frame.b_frame_interval_type);
2016 else if (frm->fmt_type == UVCG_MJPEG)
2017 h->bLength = UVC_DT_FRAME_MJPEG_SIZE(
2018 frm->frame.b_frame_interval_type);
2026 static int uvcg_streaming_class_allow_link(struct config_item *src,
2027 struct config_item *target)
2029 struct config_item *streaming, *header;
2030 struct f_uvc_opts *opts;
2031 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
2032 struct uvc_descriptor_header ***class_array, **cl_arr;
2033 struct uvcg_streaming_header *target_hdr;
2034 void *data, *data_save;
2035 size_t size = 0, count = 0;
2038 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
2040 streaming = src->ci_parent->ci_parent;
2041 header = config_group_find_item(to_config_group(streaming), "header");
2042 if (!header || target->ci_parent != header)
2045 opts = to_f_uvc_opts(streaming->ci_parent);
2047 mutex_lock(&opts->lock);
2049 class_array = __uvcg_get_stream_class_arr(src, opts);
2050 if (!class_array || *class_array || opts->refcnt) {
2055 target_hdr = to_uvcg_streaming_header(target);
2056 ret = __uvcg_iter_strm_cls(target_hdr, &size, &count, __uvcg_cnt_strm);
2060 count += 2; /* color_matching, NULL */
2061 *class_array = kcalloc(count, sizeof(void *), GFP_KERNEL);
2062 if (!*class_array) {
2067 data = data_save = kzalloc(size, GFP_KERNEL);
2069 kfree(*class_array);
2070 *class_array = NULL;
2071 ret = PTR_ERR(data);
2074 cl_arr = *class_array;
2075 ret = __uvcg_iter_strm_cls(target_hdr, &data, &cl_arr,
2078 kfree(*class_array);
2079 *class_array = NULL;
2081 * __uvcg_fill_strm() called from __uvcg_iter_stream_cls()
2082 * might have advanced the "data", so use a backup copy
2087 *cl_arr = (struct uvc_descriptor_header *)&opts->uvc_color_matching;
2089 ++target_hdr->linked;
2093 mutex_unlock(&opts->lock);
2095 config_item_put(header);
2096 mutex_unlock(su_mutex);
2100 static int uvcg_streaming_class_drop_link(struct config_item *src,
2101 struct config_item *target)
2103 struct config_item *streaming, *header;
2104 struct f_uvc_opts *opts;
2105 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
2106 struct uvc_descriptor_header ***class_array;
2107 struct uvcg_streaming_header *target_hdr;
2110 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
2112 streaming = src->ci_parent->ci_parent;
2113 header = config_group_find_item(to_config_group(streaming), "header");
2114 if (!header || target->ci_parent != header)
2117 opts = to_f_uvc_opts(streaming->ci_parent);
2119 mutex_lock(&opts->lock);
2121 class_array = __uvcg_get_stream_class_arr(src, opts);
2122 if (!class_array || !*class_array)
2130 target_hdr = to_uvcg_streaming_header(target);
2131 --target_hdr->linked;
2132 kfree(**class_array);
2133 kfree(*class_array);
2134 *class_array = NULL;
2138 mutex_unlock(&opts->lock);
2140 config_item_put(header);
2141 mutex_unlock(su_mutex);
2145 static struct configfs_item_operations uvcg_streaming_class_item_ops = {
2146 .allow_link = uvcg_streaming_class_allow_link,
2147 .drop_link = uvcg_streaming_class_drop_link,
2150 static struct config_item_type uvcg_streaming_class_type = {
2151 .ct_item_ops = &uvcg_streaming_class_item_ops,
2152 .ct_owner = THIS_MODULE,
2155 static struct config_group *uvcg_streaming_class_default_groups[] = {
2156 &uvcg_streaming_class_fs.group,
2157 &uvcg_streaming_class_hs.group,
2158 &uvcg_streaming_class_ss.group,
2162 /* streaming/class */
2163 static struct uvcg_streaming_class_grp {
2164 struct config_group group;
2165 } uvcg_streaming_class_grp;
2167 static struct config_item_type uvcg_streaming_class_grp_type = {
2168 .ct_owner = THIS_MODULE,
2171 static struct config_group *uvcg_streaming_default_groups[] = {
2172 &uvcg_streaming_header_grp.group,
2173 &uvcg_uncompressed_grp.group,
2174 &uvcg_mjpeg_grp.group,
2175 &uvcg_color_matching_grp.group,
2176 &uvcg_streaming_class_grp.group,
2181 static struct uvcg_streaming_grp {
2182 struct config_group group;
2183 } uvcg_streaming_grp;
2185 static struct config_item_type uvcg_streaming_grp_type = {
2186 .ct_owner = THIS_MODULE,
2189 static struct config_group *uvcg_default_groups[] = {
2190 &uvcg_control_grp.group,
2191 &uvcg_streaming_grp.group,
2195 static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item)
2197 return container_of(to_config_group(item), struct f_uvc_opts,
2201 static void uvc_attr_release(struct config_item *item)
2203 struct f_uvc_opts *opts = to_f_uvc_opts(item);
2205 usb_put_function_instance(&opts->func_inst);
2208 static struct configfs_item_operations uvc_item_ops = {
2209 .release = uvc_attr_release,
2212 #define UVCG_OPTS_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit) \
2213 static ssize_t f_uvc_opts_##cname##_show( \
2214 struct config_item *item, char *page) \
2216 struct f_uvc_opts *opts = to_f_uvc_opts(item); \
2219 mutex_lock(&opts->lock); \
2220 result = sprintf(page, "%d\n", conv(opts->cname)); \
2221 mutex_unlock(&opts->lock); \
2227 f_uvc_opts_##cname##_store(struct config_item *item, \
2228 const char *page, size_t len) \
2230 struct f_uvc_opts *opts = to_f_uvc_opts(item); \
2234 mutex_lock(&opts->lock); \
2235 if (opts->refcnt) { \
2240 ret = str2u(page, 0, &num); \
2244 if (num > limit) { \
2248 opts->cname = vnoc(num); \
2251 mutex_unlock(&opts->lock); \
2255 UVC_ATTR(f_uvc_opts_, cname, cname)
2257 #define identity_conv(x) (x)
2259 UVCG_OPTS_ATTR(streaming_interval, streaming_interval, identity_conv,
2260 kstrtou8, u8, identity_conv, 16);
2261 UVCG_OPTS_ATTR(streaming_maxpacket, streaming_maxpacket, le16_to_cpu,
2262 kstrtou16, u16, le16_to_cpu, 3072);
2263 UVCG_OPTS_ATTR(streaming_maxburst, streaming_maxburst, identity_conv,
2264 kstrtou8, u8, identity_conv, 15);
2266 #undef identity_conv
2268 #undef UVCG_OPTS_ATTR
2270 static struct configfs_attribute *uvc_attrs[] = {
2271 &f_uvc_opts_attr_streaming_interval,
2272 &f_uvc_opts_attr_streaming_maxpacket,
2273 &f_uvc_opts_attr_streaming_maxburst,
2277 static struct config_item_type uvc_func_type = {
2278 .ct_item_ops = &uvc_item_ops,
2279 .ct_attrs = uvc_attrs,
2280 .ct_owner = THIS_MODULE,
2283 static inline void uvcg_init_group(struct config_group *g,
2284 struct config_group **default_groups,
2286 struct config_item_type *type)
2288 g->default_groups = default_groups;
2289 config_group_init_type_name(g, name, type);
2292 int uvcg_attach_configfs(struct f_uvc_opts *opts)
2294 config_group_init_type_name(&uvcg_control_header_grp.group,
2296 &uvcg_control_header_grp_type);
2297 config_group_init_type_name(&uvcg_default_processing.group,
2299 &uvcg_default_processing_type);
2300 uvcg_init_group(&uvcg_processing_grp.group,
2301 uvcg_processing_default_groups,
2303 &uvcg_processing_grp_type);
2304 config_group_init_type_name(&uvcg_default_camera.group,
2306 &uvcg_default_camera_type);
2307 uvcg_init_group(&uvcg_camera_grp.group,
2308 uvcg_camera_default_groups,
2310 &uvcg_camera_grp_type);
2311 config_group_init_type_name(&uvcg_default_output.group,
2313 &uvcg_default_output_type);
2314 uvcg_init_group(&uvcg_output_grp.group,
2315 uvcg_output_default_groups,
2317 &uvcg_output_grp_type);
2318 uvcg_init_group(&uvcg_terminal_grp.group,
2319 uvcg_terminal_default_groups,
2321 &uvcg_terminal_grp_type);
2322 config_group_init_type_name(&uvcg_control_class_fs.group,
2324 &uvcg_control_class_type);
2325 config_group_init_type_name(&uvcg_control_class_ss.group,
2327 &uvcg_control_class_type);
2328 uvcg_init_group(&uvcg_control_class_grp.group,
2329 uvcg_control_class_default_groups,
2331 &uvcg_control_class_grp_type);
2332 uvcg_init_group(&uvcg_control_grp.group,
2333 uvcg_control_default_groups,
2335 &uvcg_control_grp_type);
2336 config_group_init_type_name(&uvcg_streaming_header_grp.group,
2338 &uvcg_streaming_header_grp_type);
2339 config_group_init_type_name(&uvcg_uncompressed_grp.group,
2341 &uvcg_uncompressed_grp_type);
2342 config_group_init_type_name(&uvcg_mjpeg_grp.group,
2344 &uvcg_mjpeg_grp_type);
2345 config_group_init_type_name(&uvcg_default_color_matching.group,
2347 &uvcg_default_color_matching_type);
2348 uvcg_init_group(&uvcg_color_matching_grp.group,
2349 uvcg_color_matching_default_groups,
2351 &uvcg_color_matching_grp_type);
2352 config_group_init_type_name(&uvcg_streaming_class_fs.group,
2354 &uvcg_streaming_class_type);
2355 config_group_init_type_name(&uvcg_streaming_class_hs.group,
2357 &uvcg_streaming_class_type);
2358 config_group_init_type_name(&uvcg_streaming_class_ss.group,
2360 &uvcg_streaming_class_type);
2361 uvcg_init_group(&uvcg_streaming_class_grp.group,
2362 uvcg_streaming_class_default_groups,
2364 &uvcg_streaming_class_grp_type);
2365 uvcg_init_group(&uvcg_streaming_grp.group,
2366 uvcg_streaming_default_groups,
2368 &uvcg_streaming_grp_type);
2369 uvcg_init_group(&opts->func_inst.group,
2370 uvcg_default_groups,