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), \
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 mutex_unlock(su_mutex);
571 static int uvcg_control_class_drop_link(struct config_item *src,
572 struct config_item *target)
574 struct config_item *control, *header;
575 struct f_uvc_opts *opts;
576 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
577 struct uvc_descriptor_header **class_array;
578 struct uvcg_control_header *target_hdr;
581 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
583 control = src->ci_parent->ci_parent;
584 header = config_group_find_item(to_config_group(control), "header");
585 if (!header || target->ci_parent != header)
588 opts = to_f_uvc_opts(control->ci_parent);
590 mutex_lock(&opts->lock);
592 class_array = uvcg_get_ctl_class_arr(src, opts);
600 target_hdr = to_uvcg_control_header(target);
601 --target_hdr->linked;
602 class_array[0] = NULL;
606 mutex_unlock(&opts->lock);
608 mutex_unlock(su_mutex);
612 static struct configfs_item_operations uvcg_control_class_item_ops = {
613 .allow_link = uvcg_control_class_allow_link,
614 .drop_link = uvcg_control_class_drop_link,
617 static struct config_item_type uvcg_control_class_type = {
618 .ct_item_ops = &uvcg_control_class_item_ops,
619 .ct_owner = THIS_MODULE,
622 static struct config_group *uvcg_control_class_default_groups[] = {
623 &uvcg_control_class_fs.group,
624 &uvcg_control_class_ss.group,
629 static struct uvcg_control_class_grp {
630 struct config_group group;
631 } uvcg_control_class_grp;
633 static struct config_item_type uvcg_control_class_grp_type = {
634 .ct_owner = THIS_MODULE,
637 static struct config_group *uvcg_control_default_groups[] = {
638 &uvcg_control_header_grp.group,
639 &uvcg_processing_grp.group,
640 &uvcg_terminal_grp.group,
641 &uvcg_control_class_grp.group,
646 static struct uvcg_control_grp {
647 struct config_group group;
650 static struct config_item_type uvcg_control_grp_type = {
651 .ct_owner = THIS_MODULE,
654 /* streaming/uncompressed */
655 static struct uvcg_uncompressed_grp {
656 struct config_group group;
657 } uvcg_uncompressed_grp;
659 /* streaming/mjpeg */
660 static struct uvcg_mjpeg_grp {
661 struct config_group group;
664 static struct config_item *fmt_parent[] = {
665 &uvcg_uncompressed_grp.group.cg_item,
666 &uvcg_mjpeg_grp.group.cg_item,
669 enum uvcg_format_type {
670 UVCG_UNCOMPRESSED = 0,
675 struct config_group group;
676 enum uvcg_format_type type;
679 __u8 bmaControls[UVCG_STREAMING_CONTROL_SIZE];
682 static struct uvcg_format *to_uvcg_format(struct config_item *item)
684 return container_of(to_config_group(item), struct uvcg_format, group);
687 static ssize_t uvcg_format_bma_controls_show(struct uvcg_format *f, char *page)
689 struct f_uvc_opts *opts;
690 struct config_item *opts_item;
691 struct mutex *su_mutex = &f->group.cg_subsys->su_mutex;
695 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
697 opts_item = f->group.cg_item.ci_parent->ci_parent->ci_parent;
698 opts = to_f_uvc_opts(opts_item);
700 mutex_lock(&opts->lock);
701 result = sprintf(pg, "0x");
703 for (i = 0; i < UVCG_STREAMING_CONTROL_SIZE; ++i) {
704 result += sprintf(pg, "%x\n", f->bmaControls[i]);
707 mutex_unlock(&opts->lock);
709 mutex_unlock(su_mutex);
713 static ssize_t uvcg_format_bma_controls_store(struct uvcg_format *ch,
714 const char *page, size_t len)
716 struct f_uvc_opts *opts;
717 struct config_item *opts_item;
718 struct mutex *su_mutex = &ch->group.cg_subsys->su_mutex;
721 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
723 opts_item = ch->group.cg_item.ci_parent->ci_parent->ci_parent;
724 opts = to_f_uvc_opts(opts_item);
726 mutex_lock(&opts->lock);
727 if (ch->linked || opts->refcnt) {
732 if (len < 4 || *page != '0' ||
733 (*(page + 1) != 'x' && *(page + 1) != 'X'))
735 ret = hex2bin(ch->bmaControls, page + 2, 1);
740 mutex_unlock(&opts->lock);
741 mutex_unlock(su_mutex);
745 struct uvcg_format_ptr {
746 struct uvcg_format *fmt;
747 struct list_head entry;
750 /* streaming/header/<NAME> */
751 struct uvcg_streaming_header {
752 struct config_item item;
753 struct uvc_input_header_descriptor desc;
755 struct list_head formats;
759 static struct uvcg_streaming_header *to_uvcg_streaming_header(struct config_item *item)
761 return container_of(item, struct uvcg_streaming_header, item);
764 static int uvcg_streaming_header_allow_link(struct config_item *src,
765 struct config_item *target)
767 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
768 struct config_item *opts_item;
769 struct f_uvc_opts *opts;
770 struct uvcg_streaming_header *src_hdr;
771 struct uvcg_format *target_fmt = NULL;
772 struct uvcg_format_ptr *format_ptr;
773 int i, ret = -EINVAL;
775 src_hdr = to_uvcg_streaming_header(src);
776 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
778 opts_item = src->ci_parent->ci_parent->ci_parent;
779 opts = to_f_uvc_opts(opts_item);
781 mutex_lock(&opts->lock);
783 if (src_hdr->linked) {
788 for (i = 0; i < ARRAY_SIZE(fmt_parent); ++i)
789 if (target->ci_parent == fmt_parent[i])
791 if (i == ARRAY_SIZE(fmt_parent))
794 target_fmt = container_of(to_config_group(target), struct uvcg_format,
799 format_ptr = kzalloc(sizeof(*format_ptr), GFP_KERNEL);
805 format_ptr->fmt = target_fmt;
806 list_add_tail(&format_ptr->entry, &src_hdr->formats);
810 mutex_unlock(&opts->lock);
811 mutex_unlock(su_mutex);
815 static int uvcg_streaming_header_drop_link(struct config_item *src,
816 struct config_item *target)
818 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
819 struct config_item *opts_item;
820 struct f_uvc_opts *opts;
821 struct uvcg_streaming_header *src_hdr;
822 struct uvcg_format *target_fmt = NULL;
823 struct uvcg_format_ptr *format_ptr, *tmp;
826 src_hdr = to_uvcg_streaming_header(src);
827 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
829 opts_item = src->ci_parent->ci_parent->ci_parent;
830 opts = to_f_uvc_opts(opts_item);
832 mutex_lock(&opts->lock);
833 target_fmt = container_of(to_config_group(target), struct uvcg_format,
838 list_for_each_entry_safe(format_ptr, tmp, &src_hdr->formats, entry)
839 if (format_ptr->fmt == target_fmt) {
840 list_del(&format_ptr->entry);
847 mutex_unlock(&opts->lock);
848 mutex_unlock(su_mutex);
853 static struct configfs_item_operations uvcg_streaming_header_item_ops = {
854 .allow_link = uvcg_streaming_header_allow_link,
855 .drop_link = uvcg_streaming_header_drop_link,
858 #define UVCG_STREAMING_HEADER_ATTR(cname, aname, conv) \
859 static ssize_t uvcg_streaming_header_##cname##_show( \
860 struct config_item *item, char *page) \
862 struct uvcg_streaming_header *sh = to_uvcg_streaming_header(item); \
863 struct f_uvc_opts *opts; \
864 struct config_item *opts_item; \
865 struct mutex *su_mutex = &sh->item.ci_group->cg_subsys->su_mutex;\
868 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
870 opts_item = sh->item.ci_parent->ci_parent->ci_parent; \
871 opts = to_f_uvc_opts(opts_item); \
873 mutex_lock(&opts->lock); \
874 result = sprintf(page, "%d\n", conv(sh->desc.aname)); \
875 mutex_unlock(&opts->lock); \
877 mutex_unlock(su_mutex); \
881 UVC_ATTR_RO(uvcg_streaming_header_, cname, aname)
883 #define identity_conv(x) (x)
885 UVCG_STREAMING_HEADER_ATTR(bm_info, bmInfo, identity_conv);
886 UVCG_STREAMING_HEADER_ATTR(b_terminal_link, bTerminalLink, identity_conv);
887 UVCG_STREAMING_HEADER_ATTR(b_still_capture_method, bStillCaptureMethod,
889 UVCG_STREAMING_HEADER_ATTR(b_trigger_support, bTriggerSupport, identity_conv);
890 UVCG_STREAMING_HEADER_ATTR(b_trigger_usage, bTriggerUsage, identity_conv);
894 #undef UVCG_STREAMING_HEADER_ATTR
896 static struct configfs_attribute *uvcg_streaming_header_attrs[] = {
897 &uvcg_streaming_header_attr_bm_info,
898 &uvcg_streaming_header_attr_b_terminal_link,
899 &uvcg_streaming_header_attr_b_still_capture_method,
900 &uvcg_streaming_header_attr_b_trigger_support,
901 &uvcg_streaming_header_attr_b_trigger_usage,
905 static struct config_item_type uvcg_streaming_header_type = {
906 .ct_item_ops = &uvcg_streaming_header_item_ops,
907 .ct_attrs = uvcg_streaming_header_attrs,
908 .ct_owner = THIS_MODULE,
911 static struct config_item
912 *uvcg_streaming_header_make(struct config_group *group, const char *name)
914 struct uvcg_streaming_header *h;
916 h = kzalloc(sizeof(*h), GFP_KERNEL);
918 return ERR_PTR(-ENOMEM);
920 INIT_LIST_HEAD(&h->formats);
921 h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
922 h->desc.bDescriptorSubType = UVC_VS_INPUT_HEADER;
923 h->desc.bTerminalLink = 3;
924 h->desc.bControlSize = UVCG_STREAMING_CONTROL_SIZE;
926 config_item_init_type_name(&h->item, name, &uvcg_streaming_header_type);
931 static void uvcg_streaming_header_drop(struct config_group *group,
932 struct config_item *item)
934 struct uvcg_streaming_header *h = to_uvcg_streaming_header(item);
939 /* streaming/header */
940 static struct uvcg_streaming_header_grp {
941 struct config_group group;
942 } uvcg_streaming_header_grp;
944 static struct configfs_group_operations uvcg_streaming_header_grp_ops = {
945 .make_item = uvcg_streaming_header_make,
946 .drop_item = uvcg_streaming_header_drop,
949 static struct config_item_type uvcg_streaming_header_grp_type = {
950 .ct_group_ops = &uvcg_streaming_header_grp_ops,
951 .ct_owner = THIS_MODULE,
954 /* streaming/<mode>/<format>/<NAME> */
958 u8 b_descriptor_type;
959 u8 b_descriptor_subtype;
966 u32 dw_max_video_frame_buffer_size;
967 u32 dw_default_frame_interval;
968 u8 b_frame_interval_type;
969 } __attribute__((packed)) frame;
970 u32 *dw_frame_interval;
971 enum uvcg_format_type fmt_type;
972 struct config_item item;
975 static struct uvcg_frame *to_uvcg_frame(struct config_item *item)
977 return container_of(item, struct uvcg_frame, item);
980 #define UVCG_FRAME_ATTR(cname, aname, to_cpu_endian, to_little_endian, bits) \
981 static ssize_t uvcg_frame_##cname##_show(struct config_item *item, char *page)\
983 struct uvcg_frame *f = to_uvcg_frame(item); \
984 struct f_uvc_opts *opts; \
985 struct config_item *opts_item; \
986 struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\
989 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
991 opts_item = f->item.ci_parent->ci_parent->ci_parent->ci_parent; \
992 opts = to_f_uvc_opts(opts_item); \
994 mutex_lock(&opts->lock); \
995 result = sprintf(page, "%d\n", to_cpu_endian(f->frame.cname)); \
996 mutex_unlock(&opts->lock); \
998 mutex_unlock(su_mutex); \
1002 static ssize_t uvcg_frame_##cname##_store(struct config_item *item, \
1003 const char *page, size_t len)\
1005 struct uvcg_frame *f = to_uvcg_frame(item); \
1006 struct f_uvc_opts *opts; \
1007 struct config_item *opts_item; \
1008 struct uvcg_format *fmt; \
1009 struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\
1013 ret = kstrtou##bits(page, 0, &num); \
1017 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1019 opts_item = f->item.ci_parent->ci_parent->ci_parent->ci_parent; \
1020 opts = to_f_uvc_opts(opts_item); \
1021 fmt = to_uvcg_format(f->item.ci_parent); \
1023 mutex_lock(&opts->lock); \
1024 if (fmt->linked || opts->refcnt) { \
1029 f->frame.cname = to_little_endian(num); \
1032 mutex_unlock(&opts->lock); \
1033 mutex_unlock(su_mutex); \
1037 UVC_ATTR(uvcg_frame_, cname, aname);
1039 #define noop_conversion(x) (x)
1041 UVCG_FRAME_ATTR(bm_capabilities, bmCapabilities, noop_conversion,
1042 noop_conversion, 8);
1043 UVCG_FRAME_ATTR(w_width, wWidth, le16_to_cpu, cpu_to_le16, 16);
1044 UVCG_FRAME_ATTR(w_height, wHeight, le16_to_cpu, cpu_to_le16, 16);
1045 UVCG_FRAME_ATTR(dw_min_bit_rate, dwMinBitRate, le32_to_cpu, cpu_to_le32, 32);
1046 UVCG_FRAME_ATTR(dw_max_bit_rate, dwMaxBitRate, le32_to_cpu, cpu_to_le32, 32);
1047 UVCG_FRAME_ATTR(dw_max_video_frame_buffer_size, dwMaxVideoFrameBufferSize,
1048 le32_to_cpu, cpu_to_le32, 32);
1049 UVCG_FRAME_ATTR(dw_default_frame_interval, dwDefaultFrameInterval,
1050 le32_to_cpu, cpu_to_le32, 32);
1052 #undef noop_conversion
1054 #undef UVCG_FRAME_ATTR
1056 static ssize_t uvcg_frame_dw_frame_interval_show(struct config_item *item,
1059 struct uvcg_frame *frm = to_uvcg_frame(item);
1060 struct f_uvc_opts *opts;
1061 struct config_item *opts_item;
1062 struct mutex *su_mutex = &frm->item.ci_group->cg_subsys->su_mutex;
1066 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
1068 opts_item = frm->item.ci_parent->ci_parent->ci_parent->ci_parent;
1069 opts = to_f_uvc_opts(opts_item);
1071 mutex_lock(&opts->lock);
1072 for (result = 0, i = 0; i < frm->frame.b_frame_interval_type; ++i) {
1073 result += sprintf(pg, "%d\n",
1074 le32_to_cpu(frm->dw_frame_interval[i]));
1077 mutex_unlock(&opts->lock);
1079 mutex_unlock(su_mutex);
1083 static inline int __uvcg_count_frm_intrv(char *buf, void *priv)
1089 static inline int __uvcg_fill_frm_intrv(char *buf, void *priv)
1094 ret = kstrtou32(buf, 0, &num);
1099 **interv = cpu_to_le32(num);
1105 static int __uvcg_iter_frm_intrv(const char *page, size_t len,
1106 int (*fun)(char *, void *), void *priv)
1108 /* sign, base 2 representation, newline, terminator */
1109 char buf[1 + sizeof(u32) * 8 + 1 + 1];
1110 const char *pg = page;
1116 while (pg - page < len) {
1118 while (i < sizeof(buf) && (pg - page < len) &&
1119 *pg != '\0' && *pg != '\n')
1121 if (i == sizeof(buf))
1123 while ((pg - page < len) && (*pg == '\0' || *pg == '\n'))
1126 ret = fun(buf, priv);
1134 static ssize_t uvcg_frame_dw_frame_interval_store(struct config_item *item,
1135 const char *page, size_t len)
1137 struct uvcg_frame *ch = to_uvcg_frame(item);
1138 struct f_uvc_opts *opts;
1139 struct config_item *opts_item;
1140 struct uvcg_format *fmt;
1141 struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;
1143 u32 *frm_intrv, *tmp;
1145 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
1147 opts_item = ch->item.ci_parent->ci_parent->ci_parent->ci_parent;
1148 opts = to_f_uvc_opts(opts_item);
1149 fmt = to_uvcg_format(ch->item.ci_parent);
1151 mutex_lock(&opts->lock);
1152 if (fmt->linked || opts->refcnt) {
1157 ret = __uvcg_iter_frm_intrv(page, len, __uvcg_count_frm_intrv, &n);
1161 tmp = frm_intrv = kcalloc(n, sizeof(u32), GFP_KERNEL);
1167 ret = __uvcg_iter_frm_intrv(page, len, __uvcg_fill_frm_intrv, &tmp);
1173 kfree(ch->dw_frame_interval);
1174 ch->dw_frame_interval = frm_intrv;
1175 ch->frame.b_frame_interval_type = n;
1179 mutex_unlock(&opts->lock);
1180 mutex_unlock(su_mutex);
1184 UVC_ATTR(uvcg_frame_, dw_frame_interval, dwFrameInterval);
1186 static struct configfs_attribute *uvcg_frame_attrs[] = {
1187 &uvcg_frame_attr_bm_capabilities,
1188 &uvcg_frame_attr_w_width,
1189 &uvcg_frame_attr_w_height,
1190 &uvcg_frame_attr_dw_min_bit_rate,
1191 &uvcg_frame_attr_dw_max_bit_rate,
1192 &uvcg_frame_attr_dw_max_video_frame_buffer_size,
1193 &uvcg_frame_attr_dw_default_frame_interval,
1194 &uvcg_frame_attr_dw_frame_interval,
1198 static struct config_item_type uvcg_frame_type = {
1199 .ct_attrs = uvcg_frame_attrs,
1200 .ct_owner = THIS_MODULE,
1203 static struct config_item *uvcg_frame_make(struct config_group *group,
1206 struct uvcg_frame *h;
1207 struct uvcg_format *fmt;
1208 struct f_uvc_opts *opts;
1209 struct config_item *opts_item;
1211 h = kzalloc(sizeof(*h), GFP_KERNEL);
1213 return ERR_PTR(-ENOMEM);
1215 h->frame.b_descriptor_type = USB_DT_CS_INTERFACE;
1216 h->frame.b_frame_index = 1;
1217 h->frame.w_width = cpu_to_le16(640);
1218 h->frame.w_height = cpu_to_le16(360);
1219 h->frame.dw_min_bit_rate = cpu_to_le32(18432000);
1220 h->frame.dw_max_bit_rate = cpu_to_le32(55296000);
1221 h->frame.dw_max_video_frame_buffer_size = cpu_to_le32(460800);
1222 h->frame.dw_default_frame_interval = cpu_to_le32(666666);
1224 opts_item = group->cg_item.ci_parent->ci_parent->ci_parent;
1225 opts = to_f_uvc_opts(opts_item);
1227 mutex_lock(&opts->lock);
1228 fmt = to_uvcg_format(&group->cg_item);
1229 if (fmt->type == UVCG_UNCOMPRESSED) {
1230 h->frame.b_descriptor_subtype = UVC_VS_FRAME_UNCOMPRESSED;
1231 h->fmt_type = UVCG_UNCOMPRESSED;
1232 } else if (fmt->type == UVCG_MJPEG) {
1233 h->frame.b_descriptor_subtype = UVC_VS_FRAME_MJPEG;
1234 h->fmt_type = UVCG_MJPEG;
1236 mutex_unlock(&opts->lock);
1238 return ERR_PTR(-EINVAL);
1241 mutex_unlock(&opts->lock);
1243 config_item_init_type_name(&h->item, name, &uvcg_frame_type);
1248 static void uvcg_frame_drop(struct config_group *group, struct config_item *item)
1250 struct uvcg_frame *h = to_uvcg_frame(item);
1251 struct uvcg_format *fmt;
1252 struct f_uvc_opts *opts;
1253 struct config_item *opts_item;
1255 opts_item = group->cg_item.ci_parent->ci_parent->ci_parent;
1256 opts = to_f_uvc_opts(opts_item);
1258 mutex_lock(&opts->lock);
1259 fmt = to_uvcg_format(&group->cg_item);
1262 mutex_unlock(&opts->lock);
1265 /* streaming/uncompressed/<NAME> */
1266 struct uvcg_uncompressed {
1267 struct uvcg_format fmt;
1268 struct uvc_format_uncompressed desc;
1271 static struct uvcg_uncompressed *to_uvcg_uncompressed(struct config_item *item)
1273 return container_of(
1274 container_of(to_config_group(item), struct uvcg_format, group),
1275 struct uvcg_uncompressed, fmt);
1278 static struct configfs_group_operations uvcg_uncompressed_group_ops = {
1279 .make_item = uvcg_frame_make,
1280 .drop_item = uvcg_frame_drop,
1283 static ssize_t uvcg_uncompressed_guid_format_show(struct config_item *item,
1286 struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item);
1287 struct f_uvc_opts *opts;
1288 struct config_item *opts_item;
1289 struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex;
1291 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
1293 opts_item = ch->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;
1294 opts = to_f_uvc_opts(opts_item);
1296 mutex_lock(&opts->lock);
1297 memcpy(page, ch->desc.guidFormat, sizeof(ch->desc.guidFormat));
1298 mutex_unlock(&opts->lock);
1300 mutex_unlock(su_mutex);
1302 return sizeof(ch->desc.guidFormat);
1305 static ssize_t uvcg_uncompressed_guid_format_store(struct config_item *item,
1306 const char *page, size_t len)
1308 struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item);
1309 struct f_uvc_opts *opts;
1310 struct config_item *opts_item;
1311 struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex;
1314 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
1316 opts_item = ch->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;
1317 opts = to_f_uvc_opts(opts_item);
1319 mutex_lock(&opts->lock);
1320 if (ch->fmt.linked || opts->refcnt) {
1325 memcpy(ch->desc.guidFormat, page,
1326 min(sizeof(ch->desc.guidFormat), len));
1327 ret = sizeof(ch->desc.guidFormat);
1330 mutex_unlock(&opts->lock);
1331 mutex_unlock(su_mutex);
1335 UVC_ATTR(uvcg_uncompressed_, guid_format, guidFormat);
1337 #define UVCG_UNCOMPRESSED_ATTR_RO(cname, aname, conv) \
1338 static ssize_t uvcg_uncompressed_##cname##_show( \
1339 struct config_item *item, char *page) \
1341 struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
1342 struct f_uvc_opts *opts; \
1343 struct config_item *opts_item; \
1344 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1347 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1349 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1350 opts = to_f_uvc_opts(opts_item); \
1352 mutex_lock(&opts->lock); \
1353 result = sprintf(page, "%d\n", conv(u->desc.aname)); \
1354 mutex_unlock(&opts->lock); \
1356 mutex_unlock(su_mutex); \
1360 UVC_ATTR_RO(uvcg_uncompressed_, cname, aname);
1362 #define UVCG_UNCOMPRESSED_ATTR(cname, aname, conv) \
1363 static ssize_t uvcg_uncompressed_##cname##_show( \
1364 struct config_item *item, char *page) \
1366 struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
1367 struct f_uvc_opts *opts; \
1368 struct config_item *opts_item; \
1369 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1372 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1374 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1375 opts = to_f_uvc_opts(opts_item); \
1377 mutex_lock(&opts->lock); \
1378 result = sprintf(page, "%d\n", conv(u->desc.aname)); \
1379 mutex_unlock(&opts->lock); \
1381 mutex_unlock(su_mutex); \
1386 uvcg_uncompressed_##cname##_store(struct config_item *item, \
1387 const char *page, size_t len) \
1389 struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
1390 struct f_uvc_opts *opts; \
1391 struct config_item *opts_item; \
1392 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1396 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1398 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1399 opts = to_f_uvc_opts(opts_item); \
1401 mutex_lock(&opts->lock); \
1402 if (u->fmt.linked || opts->refcnt) { \
1407 ret = kstrtou8(page, 0, &num); \
1415 u->desc.aname = num; \
1418 mutex_unlock(&opts->lock); \
1419 mutex_unlock(su_mutex); \
1423 UVC_ATTR(uvcg_uncompressed_, cname, aname);
1425 #define identity_conv(x) (x)
1427 UVCG_UNCOMPRESSED_ATTR(b_bits_per_pixel, bBitsPerPixel, identity_conv);
1428 UVCG_UNCOMPRESSED_ATTR(b_default_frame_index, bDefaultFrameIndex,
1430 UVCG_UNCOMPRESSED_ATTR_RO(b_aspect_ratio_x, bAspectRatioX, identity_conv);
1431 UVCG_UNCOMPRESSED_ATTR_RO(b_aspect_ratio_y, bAspectRatioY, identity_conv);
1432 UVCG_UNCOMPRESSED_ATTR_RO(bm_interface_flags, bmInterfaceFlags, identity_conv);
1434 #undef identity_conv
1436 #undef UVCG_UNCOMPRESSED_ATTR
1437 #undef UVCG_UNCOMPRESSED_ATTR_RO
1439 static inline ssize_t
1440 uvcg_uncompressed_bma_controls_show(struct config_item *item, char *page)
1442 struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item);
1443 return uvcg_format_bma_controls_show(&unc->fmt, page);
1446 static inline ssize_t
1447 uvcg_uncompressed_bma_controls_store(struct config_item *item,
1448 const char *page, size_t len)
1450 struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item);
1451 return uvcg_format_bma_controls_store(&unc->fmt, page, len);
1454 UVC_ATTR(uvcg_uncompressed_, bma_controls, bmaControls);
1456 static struct configfs_attribute *uvcg_uncompressed_attrs[] = {
1457 &uvcg_uncompressed_attr_guid_format,
1458 &uvcg_uncompressed_attr_b_bits_per_pixel,
1459 &uvcg_uncompressed_attr_b_default_frame_index,
1460 &uvcg_uncompressed_attr_b_aspect_ratio_x,
1461 &uvcg_uncompressed_attr_b_aspect_ratio_y,
1462 &uvcg_uncompressed_attr_bm_interface_flags,
1463 &uvcg_uncompressed_attr_bma_controls,
1467 static struct config_item_type uvcg_uncompressed_type = {
1468 .ct_group_ops = &uvcg_uncompressed_group_ops,
1469 .ct_attrs = uvcg_uncompressed_attrs,
1470 .ct_owner = THIS_MODULE,
1473 static struct config_group *uvcg_uncompressed_make(struct config_group *group,
1476 static char guid[] = {
1477 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00,
1478 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
1480 struct uvcg_uncompressed *h;
1482 h = kzalloc(sizeof(*h), GFP_KERNEL);
1484 return ERR_PTR(-ENOMEM);
1486 h->desc.bLength = UVC_DT_FORMAT_UNCOMPRESSED_SIZE;
1487 h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
1488 h->desc.bDescriptorSubType = UVC_VS_FORMAT_UNCOMPRESSED;
1489 memcpy(h->desc.guidFormat, guid, sizeof(guid));
1490 h->desc.bBitsPerPixel = 16;
1491 h->desc.bDefaultFrameIndex = 1;
1492 h->desc.bAspectRatioX = 0;
1493 h->desc.bAspectRatioY = 0;
1494 h->desc.bmInterfaceFlags = 0;
1495 h->desc.bCopyProtect = 0;
1497 h->fmt.type = UVCG_UNCOMPRESSED;
1498 config_group_init_type_name(&h->fmt.group, name,
1499 &uvcg_uncompressed_type);
1501 return &h->fmt.group;
1504 static void uvcg_uncompressed_drop(struct config_group *group,
1505 struct config_item *item)
1507 struct uvcg_uncompressed *h = to_uvcg_uncompressed(item);
1512 static struct configfs_group_operations uvcg_uncompressed_grp_ops = {
1513 .make_group = uvcg_uncompressed_make,
1514 .drop_item = uvcg_uncompressed_drop,
1517 static struct config_item_type uvcg_uncompressed_grp_type = {
1518 .ct_group_ops = &uvcg_uncompressed_grp_ops,
1519 .ct_owner = THIS_MODULE,
1522 /* streaming/mjpeg/<NAME> */
1524 struct uvcg_format fmt;
1525 struct uvc_format_mjpeg desc;
1528 static struct uvcg_mjpeg *to_uvcg_mjpeg(struct config_item *item)
1530 return container_of(
1531 container_of(to_config_group(item), struct uvcg_format, group),
1532 struct uvcg_mjpeg, fmt);
1535 static struct configfs_group_operations uvcg_mjpeg_group_ops = {
1536 .make_item = uvcg_frame_make,
1537 .drop_item = uvcg_frame_drop,
1540 #define UVCG_MJPEG_ATTR_RO(cname, aname, conv) \
1541 static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\
1543 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
1544 struct f_uvc_opts *opts; \
1545 struct config_item *opts_item; \
1546 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1549 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1551 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1552 opts = to_f_uvc_opts(opts_item); \
1554 mutex_lock(&opts->lock); \
1555 result = sprintf(page, "%d\n", conv(u->desc.aname)); \
1556 mutex_unlock(&opts->lock); \
1558 mutex_unlock(su_mutex); \
1562 UVC_ATTR_RO(uvcg_mjpeg_, cname, aname)
1564 #define UVCG_MJPEG_ATTR(cname, aname, conv) \
1565 static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\
1567 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
1568 struct f_uvc_opts *opts; \
1569 struct config_item *opts_item; \
1570 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1573 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1575 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1576 opts = to_f_uvc_opts(opts_item); \
1578 mutex_lock(&opts->lock); \
1579 result = sprintf(page, "%d\n", conv(u->desc.aname)); \
1580 mutex_unlock(&opts->lock); \
1582 mutex_unlock(su_mutex); \
1587 uvcg_mjpeg_##cname##_store(struct config_item *item, \
1588 const char *page, size_t len) \
1590 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
1591 struct f_uvc_opts *opts; \
1592 struct config_item *opts_item; \
1593 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
1597 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1599 opts_item = u->fmt.group.cg_item.ci_parent->ci_parent->ci_parent;\
1600 opts = to_f_uvc_opts(opts_item); \
1602 mutex_lock(&opts->lock); \
1603 if (u->fmt.linked || opts->refcnt) { \
1608 ret = kstrtou8(page, 0, &num); \
1616 u->desc.aname = num; \
1619 mutex_unlock(&opts->lock); \
1620 mutex_unlock(su_mutex); \
1624 UVC_ATTR(uvcg_mjpeg_, cname, aname)
1626 #define identity_conv(x) (x)
1628 UVCG_MJPEG_ATTR(b_default_frame_index, bDefaultFrameIndex,
1630 UVCG_MJPEG_ATTR_RO(bm_flags, bmFlags, identity_conv);
1631 UVCG_MJPEG_ATTR_RO(b_aspect_ratio_x, bAspectRatioX, identity_conv);
1632 UVCG_MJPEG_ATTR_RO(b_aspect_ratio_y, bAspectRatioY, identity_conv);
1633 UVCG_MJPEG_ATTR_RO(bm_interface_flags, bmInterfaceFlags, identity_conv);
1635 #undef identity_conv
1637 #undef UVCG_MJPEG_ATTR
1638 #undef UVCG_MJPEG_ATTR_RO
1640 static inline ssize_t
1641 uvcg_mjpeg_bma_controls_show(struct config_item *item, char *page)
1643 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item);
1644 return uvcg_format_bma_controls_show(&u->fmt, page);
1647 static inline ssize_t
1648 uvcg_mjpeg_bma_controls_store(struct config_item *item,
1649 const char *page, size_t len)
1651 struct uvcg_mjpeg *u = to_uvcg_mjpeg(item);
1652 return uvcg_format_bma_controls_store(&u->fmt, page, len);
1655 UVC_ATTR(uvcg_mjpeg_, bma_controls, bmaControls);
1657 static struct configfs_attribute *uvcg_mjpeg_attrs[] = {
1658 &uvcg_mjpeg_attr_b_default_frame_index,
1659 &uvcg_mjpeg_attr_bm_flags,
1660 &uvcg_mjpeg_attr_b_aspect_ratio_x,
1661 &uvcg_mjpeg_attr_b_aspect_ratio_y,
1662 &uvcg_mjpeg_attr_bm_interface_flags,
1663 &uvcg_mjpeg_attr_bma_controls,
1667 static struct config_item_type uvcg_mjpeg_type = {
1668 .ct_group_ops = &uvcg_mjpeg_group_ops,
1669 .ct_attrs = uvcg_mjpeg_attrs,
1670 .ct_owner = THIS_MODULE,
1673 static struct config_group *uvcg_mjpeg_make(struct config_group *group,
1676 struct uvcg_mjpeg *h;
1678 h = kzalloc(sizeof(*h), GFP_KERNEL);
1680 return ERR_PTR(-ENOMEM);
1682 h->desc.bLength = UVC_DT_FORMAT_MJPEG_SIZE;
1683 h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
1684 h->desc.bDescriptorSubType = UVC_VS_FORMAT_MJPEG;
1685 h->desc.bDefaultFrameIndex = 1;
1686 h->desc.bAspectRatioX = 0;
1687 h->desc.bAspectRatioY = 0;
1688 h->desc.bmInterfaceFlags = 0;
1689 h->desc.bCopyProtect = 0;
1691 h->fmt.type = UVCG_MJPEG;
1692 config_group_init_type_name(&h->fmt.group, name,
1695 return &h->fmt.group;
1698 static void uvcg_mjpeg_drop(struct config_group *group,
1699 struct config_item *item)
1701 struct uvcg_mjpeg *h = to_uvcg_mjpeg(item);
1706 static struct configfs_group_operations uvcg_mjpeg_grp_ops = {
1707 .make_group = uvcg_mjpeg_make,
1708 .drop_item = uvcg_mjpeg_drop,
1711 static struct config_item_type uvcg_mjpeg_grp_type = {
1712 .ct_group_ops = &uvcg_mjpeg_grp_ops,
1713 .ct_owner = THIS_MODULE,
1716 /* streaming/color_matching/default */
1717 static struct uvcg_default_color_matching {
1718 struct config_group group;
1719 } uvcg_default_color_matching;
1721 static inline struct uvcg_default_color_matching
1722 *to_uvcg_default_color_matching(struct config_item *item)
1724 return container_of(to_config_group(item),
1725 struct uvcg_default_color_matching, group);
1728 #define UVCG_DEFAULT_COLOR_MATCHING_ATTR(cname, aname, conv) \
1729 static ssize_t uvcg_default_color_matching_##cname##_show( \
1730 struct config_item *item, char *page) \
1732 struct uvcg_default_color_matching *dc = \
1733 to_uvcg_default_color_matching(item); \
1734 struct f_uvc_opts *opts; \
1735 struct config_item *opts_item; \
1736 struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \
1737 struct uvc_color_matching_descriptor *cd; \
1740 mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
1742 opts_item = dc->group.cg_item.ci_parent->ci_parent->ci_parent; \
1743 opts = to_f_uvc_opts(opts_item); \
1744 cd = &opts->uvc_color_matching; \
1746 mutex_lock(&opts->lock); \
1747 result = sprintf(page, "%d\n", conv(cd->aname)); \
1748 mutex_unlock(&opts->lock); \
1750 mutex_unlock(su_mutex); \
1754 UVC_ATTR_RO(uvcg_default_color_matching_, cname, aname)
1756 #define identity_conv(x) (x)
1758 UVCG_DEFAULT_COLOR_MATCHING_ATTR(b_color_primaries, bColorPrimaries,
1760 UVCG_DEFAULT_COLOR_MATCHING_ATTR(b_transfer_characteristics,
1761 bTransferCharacteristics, identity_conv);
1762 UVCG_DEFAULT_COLOR_MATCHING_ATTR(b_matrix_coefficients, bMatrixCoefficients,
1765 #undef identity_conv
1767 #undef UVCG_DEFAULT_COLOR_MATCHING_ATTR
1769 static struct configfs_attribute *uvcg_default_color_matching_attrs[] = {
1770 &uvcg_default_color_matching_attr_b_color_primaries,
1771 &uvcg_default_color_matching_attr_b_transfer_characteristics,
1772 &uvcg_default_color_matching_attr_b_matrix_coefficients,
1776 static struct config_item_type uvcg_default_color_matching_type = {
1777 .ct_attrs = uvcg_default_color_matching_attrs,
1778 .ct_owner = THIS_MODULE,
1781 /* struct uvcg_color_matching {}; */
1783 static struct config_group *uvcg_color_matching_default_groups[] = {
1784 &uvcg_default_color_matching.group,
1788 /* streaming/color_matching */
1789 static struct uvcg_color_matching_grp {
1790 struct config_group group;
1791 } uvcg_color_matching_grp;
1793 static struct config_item_type uvcg_color_matching_grp_type = {
1794 .ct_owner = THIS_MODULE,
1797 /* streaming/class/{fs|hs|ss} */
1798 static struct uvcg_streaming_class {
1799 struct config_group group;
1800 } uvcg_streaming_class_fs, uvcg_streaming_class_hs, uvcg_streaming_class_ss;
1803 static inline struct uvc_descriptor_header
1804 ***__uvcg_get_stream_class_arr(struct config_item *i, struct f_uvc_opts *o)
1806 struct uvcg_streaming_class *cl = container_of(to_config_group(i),
1807 struct uvcg_streaming_class, group);
1809 if (cl == &uvcg_streaming_class_fs)
1810 return &o->uvc_fs_streaming_cls;
1812 if (cl == &uvcg_streaming_class_hs)
1813 return &o->uvc_hs_streaming_cls;
1815 if (cl == &uvcg_streaming_class_ss)
1816 return &o->uvc_ss_streaming_cls;
1821 enum uvcg_strm_type {
1828 * Iterate over a hierarchy of streaming descriptors' config items.
1829 * The items are created by the user with configfs.
1831 * It "processes" the header pointed to by @priv1, then for each format
1832 * that follows the header "processes" the format itself and then for
1833 * each frame inside a format "processes" the frame.
1835 * As a "processing" function the @fun is used.
1837 * __uvcg_iter_strm_cls() is used in two context: first, to calculate
1838 * the amount of memory needed for an array of streaming descriptors
1839 * and second, to actually fill the array.
1841 * @h: streaming header pointer
1842 * @priv2: an "inout" parameter (the caller might want to see the changes to it)
1843 * @priv3: an "inout" parameter (the caller might want to see the changes to it)
1844 * @fun: callback function for processing each level of the hierarchy
1846 static int __uvcg_iter_strm_cls(struct uvcg_streaming_header *h,
1847 void *priv2, void *priv3,
1848 int (*fun)(void *, void *, void *, int, enum uvcg_strm_type type))
1850 struct uvcg_format_ptr *f;
1851 struct config_group *grp;
1852 struct config_item *item;
1853 struct uvcg_frame *frm;
1860 ret = fun(h, priv2, priv3, 0, UVCG_HEADER);
1863 list_for_each_entry(f, &h->formats, entry) {
1864 ret = fun(f->fmt, priv2, priv3, i++, UVCG_FORMAT);
1867 grp = &f->fmt->group;
1868 list_for_each_entry(item, &grp->cg_children, ci_entry) {
1869 frm = to_uvcg_frame(item);
1870 ret = fun(frm, priv2, priv3, j++, UVCG_FRAME);
1880 * Count how many bytes are needed for an array of streaming descriptors.
1882 * @priv1: pointer to a header, format or frame
1883 * @priv2: inout parameter, accumulated size of the array
1884 * @priv3: inout parameter, accumulated number of the array elements
1885 * @n: unused, this function's prototype must match @fun in __uvcg_iter_strm_cls
1887 static int __uvcg_cnt_strm(void *priv1, void *priv2, void *priv3, int n,
1888 enum uvcg_strm_type type)
1890 size_t *size = priv2;
1891 size_t *count = priv3;
1895 struct uvcg_streaming_header *h = priv1;
1897 *size += sizeof(h->desc);
1899 *size += h->num_fmt * UVCG_STREAMING_CONTROL_SIZE;
1903 struct uvcg_format *fmt = priv1;
1905 if (fmt->type == UVCG_UNCOMPRESSED) {
1906 struct uvcg_uncompressed *u =
1907 container_of(fmt, struct uvcg_uncompressed,
1910 *size += sizeof(u->desc);
1911 } else if (fmt->type == UVCG_MJPEG) {
1912 struct uvcg_mjpeg *m =
1913 container_of(fmt, struct uvcg_mjpeg, fmt);
1915 *size += sizeof(m->desc);
1922 struct uvcg_frame *frm = priv1;
1923 int sz = sizeof(frm->dw_frame_interval);
1925 *size += sizeof(frm->frame);
1926 *size += frm->frame.b_frame_interval_type * sz;
1937 * Fill an array of streaming descriptors.
1939 * @priv1: pointer to a header, format or frame
1940 * @priv2: inout parameter, pointer into a block of memory
1941 * @priv3: inout parameter, pointer to a 2-dimensional array
1943 static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n,
1944 enum uvcg_strm_type type)
1946 void **dest = priv2;
1947 struct uvc_descriptor_header ***array = priv3;
1955 struct uvc_input_header_descriptor *ihdr = *dest;
1956 struct uvcg_streaming_header *h = priv1;
1957 struct uvcg_format_ptr *f;
1959 memcpy(*dest, &h->desc, sizeof(h->desc));
1960 *dest += sizeof(h->desc);
1961 sz = UVCG_STREAMING_CONTROL_SIZE;
1962 list_for_each_entry(f, &h->formats, entry) {
1963 memcpy(*dest, f->fmt->bmaControls, sz);
1966 ihdr->bLength = sizeof(h->desc) + h->num_fmt * sz;
1967 ihdr->bNumFormats = h->num_fmt;
1971 struct uvcg_format *fmt = priv1;
1973 if (fmt->type == UVCG_UNCOMPRESSED) {
1974 struct uvc_format_uncompressed *unc = *dest;
1975 struct uvcg_uncompressed *u =
1976 container_of(fmt, struct uvcg_uncompressed,
1979 memcpy(*dest, &u->desc, sizeof(u->desc));
1980 *dest += sizeof(u->desc);
1981 unc->bNumFrameDescriptors = fmt->num_frames;
1982 unc->bFormatIndex = n + 1;
1983 } else if (fmt->type == UVCG_MJPEG) {
1984 struct uvc_format_mjpeg *mjp = *dest;
1985 struct uvcg_mjpeg *m =
1986 container_of(fmt, struct uvcg_mjpeg, fmt);
1988 memcpy(*dest, &m->desc, sizeof(m->desc));
1989 *dest += sizeof(m->desc);
1990 mjp->bNumFrameDescriptors = fmt->num_frames;
1991 mjp->bFormatIndex = n + 1;
1998 struct uvcg_frame *frm = priv1;
1999 struct uvc_descriptor_header *h = *dest;
2001 sz = sizeof(frm->frame);
2002 memcpy(*dest, &frm->frame, sz);
2004 sz = frm->frame.b_frame_interval_type *
2005 sizeof(*frm->dw_frame_interval);
2006 memcpy(*dest, frm->dw_frame_interval, sz);
2008 if (frm->fmt_type == UVCG_UNCOMPRESSED)
2009 h->bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE(
2010 frm->frame.b_frame_interval_type);
2011 else if (frm->fmt_type == UVCG_MJPEG)
2012 h->bLength = UVC_DT_FRAME_MJPEG_SIZE(
2013 frm->frame.b_frame_interval_type);
2021 static int uvcg_streaming_class_allow_link(struct config_item *src,
2022 struct config_item *target)
2024 struct config_item *streaming, *header;
2025 struct f_uvc_opts *opts;
2026 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
2027 struct uvc_descriptor_header ***class_array, **cl_arr;
2028 struct uvcg_streaming_header *target_hdr;
2029 void *data, *data_save;
2030 size_t size = 0, count = 0;
2033 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
2035 streaming = src->ci_parent->ci_parent;
2036 header = config_group_find_item(to_config_group(streaming), "header");
2037 if (!header || target->ci_parent != header)
2040 opts = to_f_uvc_opts(streaming->ci_parent);
2042 mutex_lock(&opts->lock);
2044 class_array = __uvcg_get_stream_class_arr(src, opts);
2045 if (!class_array || *class_array || opts->refcnt) {
2050 target_hdr = to_uvcg_streaming_header(target);
2051 ret = __uvcg_iter_strm_cls(target_hdr, &size, &count, __uvcg_cnt_strm);
2055 count += 2; /* color_matching, NULL */
2056 *class_array = kcalloc(count, sizeof(void *), GFP_KERNEL);
2057 if (!*class_array) {
2062 data = data_save = kzalloc(size, GFP_KERNEL);
2064 kfree(*class_array);
2065 *class_array = NULL;
2066 ret = PTR_ERR(data);
2069 cl_arr = *class_array;
2070 ret = __uvcg_iter_strm_cls(target_hdr, &data, &cl_arr,
2073 kfree(*class_array);
2074 *class_array = NULL;
2076 * __uvcg_fill_strm() called from __uvcg_iter_stream_cls()
2077 * might have advanced the "data", so use a backup copy
2082 *cl_arr = (struct uvc_descriptor_header *)&opts->uvc_color_matching;
2084 ++target_hdr->linked;
2088 mutex_unlock(&opts->lock);
2090 mutex_unlock(su_mutex);
2094 static int uvcg_streaming_class_drop_link(struct config_item *src,
2095 struct config_item *target)
2097 struct config_item *streaming, *header;
2098 struct f_uvc_opts *opts;
2099 struct mutex *su_mutex = &src->ci_group->cg_subsys->su_mutex;
2100 struct uvc_descriptor_header ***class_array;
2101 struct uvcg_streaming_header *target_hdr;
2104 mutex_lock(su_mutex); /* for navigating configfs hierarchy */
2106 streaming = src->ci_parent->ci_parent;
2107 header = config_group_find_item(to_config_group(streaming), "header");
2108 if (!header || target->ci_parent != header)
2111 opts = to_f_uvc_opts(streaming->ci_parent);
2113 mutex_lock(&opts->lock);
2115 class_array = __uvcg_get_stream_class_arr(src, opts);
2116 if (!class_array || !*class_array)
2124 target_hdr = to_uvcg_streaming_header(target);
2125 --target_hdr->linked;
2126 kfree(**class_array);
2127 kfree(*class_array);
2128 *class_array = NULL;
2132 mutex_unlock(&opts->lock);
2134 mutex_unlock(su_mutex);
2138 static struct configfs_item_operations uvcg_streaming_class_item_ops = {
2139 .allow_link = uvcg_streaming_class_allow_link,
2140 .drop_link = uvcg_streaming_class_drop_link,
2143 static struct config_item_type uvcg_streaming_class_type = {
2144 .ct_item_ops = &uvcg_streaming_class_item_ops,
2145 .ct_owner = THIS_MODULE,
2148 static struct config_group *uvcg_streaming_class_default_groups[] = {
2149 &uvcg_streaming_class_fs.group,
2150 &uvcg_streaming_class_hs.group,
2151 &uvcg_streaming_class_ss.group,
2155 /* streaming/class */
2156 static struct uvcg_streaming_class_grp {
2157 struct config_group group;
2158 } uvcg_streaming_class_grp;
2160 static struct config_item_type uvcg_streaming_class_grp_type = {
2161 .ct_owner = THIS_MODULE,
2164 static struct config_group *uvcg_streaming_default_groups[] = {
2165 &uvcg_streaming_header_grp.group,
2166 &uvcg_uncompressed_grp.group,
2167 &uvcg_mjpeg_grp.group,
2168 &uvcg_color_matching_grp.group,
2169 &uvcg_streaming_class_grp.group,
2174 static struct uvcg_streaming_grp {
2175 struct config_group group;
2176 } uvcg_streaming_grp;
2178 static struct config_item_type uvcg_streaming_grp_type = {
2179 .ct_owner = THIS_MODULE,
2182 static struct config_group *uvcg_default_groups[] = {
2183 &uvcg_control_grp.group,
2184 &uvcg_streaming_grp.group,
2188 static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item)
2190 return container_of(to_config_group(item), struct f_uvc_opts,
2194 static void uvc_attr_release(struct config_item *item)
2196 struct f_uvc_opts *opts = to_f_uvc_opts(item);
2198 usb_put_function_instance(&opts->func_inst);
2201 static struct configfs_item_operations uvc_item_ops = {
2202 .release = uvc_attr_release,
2205 #define UVCG_OPTS_ATTR(cname, conv, str2u, uxx, vnoc, limit) \
2206 static ssize_t f_uvc_opts_##cname##_show( \
2207 struct config_item *item, char *page) \
2209 struct f_uvc_opts *opts = to_f_uvc_opts(item); \
2212 mutex_lock(&opts->lock); \
2213 result = sprintf(page, "%d\n", conv(opts->cname)); \
2214 mutex_unlock(&opts->lock); \
2220 f_uvc_opts_##cname##_store(struct config_item *item, \
2221 const char *page, size_t len) \
2223 struct f_uvc_opts *opts = to_f_uvc_opts(item); \
2227 mutex_lock(&opts->lock); \
2228 if (opts->refcnt) { \
2233 ret = str2u(page, 0, &num); \
2237 if (num > limit) { \
2241 opts->cname = vnoc(num); \
2244 mutex_unlock(&opts->lock); \
2248 UVC_ATTR(f_uvc_opts_, cname, aname)
2250 #define identity_conv(x) (x)
2252 UVCG_OPTS_ATTR(streaming_interval, identity_conv, kstrtou8, u8, identity_conv,
2254 UVCG_OPTS_ATTR(streaming_maxpacket, le16_to_cpu, kstrtou16, u16, le16_to_cpu,
2256 UVCG_OPTS_ATTR(streaming_maxburst, identity_conv, kstrtou8, u8, identity_conv,
2259 #undef identity_conv
2261 #undef UVCG_OPTS_ATTR
2263 static struct configfs_attribute *uvc_attrs[] = {
2264 &f_uvc_opts_attr_streaming_interval,
2265 &f_uvc_opts_attr_streaming_maxpacket,
2266 &f_uvc_opts_attr_streaming_maxburst,
2270 static struct config_item_type uvc_func_type = {
2271 .ct_item_ops = &uvc_item_ops,
2272 .ct_attrs = uvc_attrs,
2273 .ct_owner = THIS_MODULE,
2276 static inline void uvcg_init_group(struct config_group *g,
2277 struct config_group **default_groups,
2279 struct config_item_type *type)
2281 g->default_groups = default_groups;
2282 config_group_init_type_name(g, name, type);
2285 int uvcg_attach_configfs(struct f_uvc_opts *opts)
2287 config_group_init_type_name(&uvcg_control_header_grp.group,
2289 &uvcg_control_header_grp_type);
2290 config_group_init_type_name(&uvcg_default_processing.group,
2292 &uvcg_default_processing_type);
2293 uvcg_init_group(&uvcg_processing_grp.group,
2294 uvcg_processing_default_groups,
2296 &uvcg_processing_grp_type);
2297 config_group_init_type_name(&uvcg_default_camera.group,
2299 &uvcg_default_camera_type);
2300 uvcg_init_group(&uvcg_camera_grp.group,
2301 uvcg_camera_default_groups,
2303 &uvcg_camera_grp_type);
2304 config_group_init_type_name(&uvcg_default_output.group,
2306 &uvcg_default_output_type);
2307 uvcg_init_group(&uvcg_output_grp.group,
2308 uvcg_output_default_groups,
2310 &uvcg_output_grp_type);
2311 uvcg_init_group(&uvcg_terminal_grp.group,
2312 uvcg_terminal_default_groups,
2314 &uvcg_terminal_grp_type);
2315 config_group_init_type_name(&uvcg_control_class_fs.group,
2317 &uvcg_control_class_type);
2318 config_group_init_type_name(&uvcg_control_class_ss.group,
2320 &uvcg_control_class_type);
2321 uvcg_init_group(&uvcg_control_class_grp.group,
2322 uvcg_control_class_default_groups,
2324 &uvcg_control_class_grp_type);
2325 uvcg_init_group(&uvcg_control_grp.group,
2326 uvcg_control_default_groups,
2328 &uvcg_control_grp_type);
2329 config_group_init_type_name(&uvcg_streaming_header_grp.group,
2331 &uvcg_streaming_header_grp_type);
2332 config_group_init_type_name(&uvcg_uncompressed_grp.group,
2334 &uvcg_uncompressed_grp_type);
2335 config_group_init_type_name(&uvcg_mjpeg_grp.group,
2337 &uvcg_mjpeg_grp_type);
2338 config_group_init_type_name(&uvcg_default_color_matching.group,
2340 &uvcg_default_color_matching_type);
2341 uvcg_init_group(&uvcg_color_matching_grp.group,
2342 uvcg_color_matching_default_groups,
2344 &uvcg_color_matching_grp_type);
2345 config_group_init_type_name(&uvcg_streaming_class_fs.group,
2347 &uvcg_streaming_class_type);
2348 config_group_init_type_name(&uvcg_streaming_class_hs.group,
2350 &uvcg_streaming_class_type);
2351 config_group_init_type_name(&uvcg_streaming_class_ss.group,
2353 &uvcg_streaming_class_type);
2354 uvcg_init_group(&uvcg_streaming_class_grp.group,
2355 uvcg_streaming_class_default_groups,
2357 &uvcg_streaming_class_grp_type);
2358 uvcg_init_group(&uvcg_streaming_grp.group,
2359 uvcg_streaming_default_groups,
2361 &uvcg_streaming_grp_type);
2362 uvcg_init_group(&opts->func_inst.group,
2363 uvcg_default_groups,